首先使用propertychanged.fody与WPF数据绑定和EF 6.0数据库。 [英] Using propertychanged.fody with WPF databinding and EF 6.0 database first.

查看:902
本文介绍了首先使用propertychanged.fody与WPF数据绑定和EF 6.0数据库。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何让PropertyChanged.Fody首先使用WPF数据绑定和EF 6.0数据库吗? 
我没有使用MVVM。
我有一个名为Test的EF生成类如下....



  //   ------------------------------- -----------------------------------------------  
// <自动生成>
// 此代码是从模板生成的。
//
// 手动更改为此文件可能会导致应用程序出现意外行为。
// 此文件的手动更改将如果重新生成代码,则会被覆盖。
// < / auto-generated>
// ----------------------------------------- -------------------------------------


< span class =code-keyword> namespace RMS_EF6
{
使用系统;
使用 System.Collections.ObjectModel;

public partial class 测试
{
public int TestIdentityKey {获得; set ; }
public Nullable< int> TestNumber1 { get ; set ; }
public Nullable< int> TestNumber2 { get ; set ; }
public string TestDescription1 { get ; set ; }
}
}



我创建了以下PropertyChanged.Fody类,如下所示.... / pre> 

 使用 PropertyChanged; 

[AddINotifyPropertyChangedInterfaceAttribute]
public partial class 测试
{
私人 void ArithmeticTest()
{
TestNumber1 = 2 * TestNumber2;
Console.WriteLine($ TestNumber1 = {TestNumber1} \ n + TestNumber2 = {TestNumber2}< /跨度>);
}
}



我可以通过WPF GUI手动输入来更新数据库中的各个字段使用WPF数据绑定。 

但是,当用户通过GUI输入数据时,我想在代码隐藏中执行类似ArithmeticTest()的方法。例如,当TestNumber2的值因用户输入而改变时。
任何人都可以告诉我需要添加到我的代码中才能实现这一目标吗?





我是什么尝试过:



我一直在试验上面的代码并且无处可去。

解决方案

TestNumber1 = {TestNumber1} \ n + TestNumber2 = {TestNumber2});
}
}



我可以通过WPF GUI手动输入来更新数据库中的各个字段使用WPF数据绑定。 

但是,当用户通过GUI输入数据时,我想在代码隐藏中执行类似ArithmeticTest()的方法。例如,当TestNumber2的值因用户输入而改变时。
任何人都可以告诉我需要添加到我的代码中才能实现这一目标吗?





我是什么尝试过:



我一直在试验上面的代码并且无处可去。


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?



What I have tried:

I have been experimenting with the code above and have gotten nowhere.

解决方案

"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?



What I have tried:

I have been experimenting with the code above and have gotten nowhere.


这篇关于首先使用propertychanged.fody与WPF数据绑定和EF 6.0数据库。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆