Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 创建WPFon showdialog事件_C#_Wpf_Entity Framework 4_Wpfdatagrid - Fatal编程技术网

C# 创建WPFon showdialog事件

C# 创建WPFon showdialog事件,c#,wpf,entity-framework-4,wpfdatagrid,C#,Wpf,Entity Framework 4,Wpfdatagrid,我正在使用创建一个新的窗口弹出窗口 PopupWindows.PaymentsSummary paymentsSummary = new PopupWindows.PaymentsSummary paymentsSummary.ParentWindow = Window.GetWindow(this); paymentsSummary.ShowDialog(); 在付款汇总窗口中的加载函数中 private void Window_Loaded(object sender, Rou

我正在使用创建一个新的窗口弹出窗口

PopupWindows.PaymentsSummary paymentsSummary = new PopupWindows.PaymentsSummary  
paymentsSummary.ParentWindow = Window.GetWindow(this);
paymentsSummary.ShowDialog();
在付款汇总窗口中的加载函数中

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        basepage.payments.BindPaymentSummaryToDataGrid(uiActiveItems, basepage.user.terminal.TerminalId, true);
        basepage.payments.BindPaymentSummaryToDataGrid(uiInActiveItems, basepage.user.terminal.TerminalId, false);
    }
功能是

    public void BindPaymentSummaryToDataGrid(DataGrid dgrid, int terminalId, bool isActivePayment)
    {
        BLPinNumber pins = new BLPinNumber();
        string pinNumber = String.Empty;
        long pinId = pins.getPinId(terminalId, ref pinNumber);
        using (var dbEntities = new DatabaseAccess.Schema.Entities())
        {
              dgrid.DataContext = dbEntities.getPaymentRecordsByPinId((int)pinId, isActivePayment);
        }
    }
上面的代码调用SQL Server中的存储过程并返回一个对象

但是,当应用程序运行时,我在单击以下行paymentsSummary.ShowDialog()显示弹出窗口时出错

我在XAML中为datagrid编写了以下代码

DataGrid  ItemsSource="{Binding}" Grid.Column="{Binding}"
如果我删除这段代码,它会工作,但数据不会明显加载

所以我认为我需要做的是绑定datagrid onShowDialog方法

我如何创建这个

或者有没有更好的方法使用Entity framework来实现这一点,我习惯于ASP.NET,在ASP.NET中,使用数据网格似乎更容易,但功能却不那么强大


非常感谢

您的问题是延迟加载!,你有两个选择:

  • 选择具有即时加载的数据(更改getPaymentRecordsByPinId)
  • 当弹出窗口打开时,不要处理dbEntities

  • 您的问题是延迟加载!,你有两个选择:

  • 选择具有即时加载的数据(更改getPaymentRecordsByPinId)
  • 当弹出窗口打开时,不要处理dbEntities

  • 我以为存储过程(getPaymentRecordsByPinId)中的所有数据都是在运行时加载的?并被分配到数据网格。数据内容。。。如果不是这种情况,我如何更改SP,使其以快速加载方式加载?使用linq获取数据效果很好。我以为存储过程(getPaymentRecordsByPinId)中的所有数据都是在运行时加载的?并被分配到数据网格。数据内容。。。如果不是这种情况,我如何更改SP,使其以快速加载方式加载?使用linq获取数据效果很好。
    DataGrid  ItemsSource="{Binding}" Grid.Column="{Binding}"