Member 12489631 Ответов: 0

Использование propertychanged.Фоды с помощью WPF привязки данных и базы данных эф 6.0 в первую очередь.


Can someone please advise me how I can get PropertyChanged.Fody to work with WPF databinding and EF 6.0 Database first?
I am not using MVVM.
I have an EF generated class called "Test" as follows....

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Manual changes to this file may cause unexpected behavior in your application.
//     Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace RMS_EF6
{
    using System;
    using System.Collections.ObjectModel;
    
    public partial class Test
    {
        public int TestIdentityKey { get; set; }
        public Nullable<int> TestNumber1 { get; set; }
        public Nullable<int> TestNumber2 { get; set; }
        public string TestDescription1 { get; set; }
    }
}

I have created the following PropertyChanged.Fody class as follows....

using PropertyChanged;

    [AddINotifyPropertyChangedInterfaceAttribute]
    public partial class Test
    {
        private void ArithmeticTest()
        {
            TestNumber1 = 2 * TestNumber2;
            Console.WriteLine($"TestNumber1 = {TestNumber1} \n + TestNumber2 = {TestNumber2}");
        }
    }

I can update the individual fields in the database with manual input through the WPF GUI OK using WPF databinding.

However, I want to execute methods like ArithmeticTest() in the code-behind when the users enter data through the GUI.  Eg when the value of TestNumber2 changes as a result of user input.
Can anyone please tell me what I need to add to my code to make this happen?


Что я уже пробовал:

Я экспериментировал с приведенным выше кодом и ничего не добился.

0 Ответов