【发布时间】:2021-03-21 17:02:41
【问题描述】:
这是我在网上找到的一篇文章,用于在 WPF Datagrid 中整理数据: Grouping in DataGrid in WPF
我想在 WPF 应用程序中使用来自实体框架 DataContext 的数据对其进行测试。
首先我想检查DataGrid 中的数据是否正确实现。
但是DataGrid 保持为空。
这是可能的xaml:
<UserControl x:Class="GESTION_CONGELATION_V2.User_Controls.ViewPvi_UC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<DataGrid x:Name="Pvi_DT">
</DataGrid>
</UserControl>
我的 .cs
public partial class ViewPvi_UC : UserControl
{
ObservableCollection<VW_PVI_2> pvi = new ObservableCollection<VW_PVI_2>();
public ViewPvi_UC()
{
InitializeComponent();
ObservableCollection<VW_PVI_2> pvi = new ObservableCollection<VW_PVI_2>();
Pvi_DT.ItemsSource = pvi;
}
}
和我的实体框架类
public partial class VW_PVI_2
{
public int PVI_ID { get; set; }
public string VE_NOM { get; set; }
public string VD_VIRTUAL { get; set; }
public string VE_OLD_NAME { get; set; }
public string ST_LIB { get; set; }
public string VE_COMM { get; set; }
public string IMP_NOM { get; set; }
public string IMP_IP { get; set; }
public string IMP_MAC { get; set; }
public string ST_LIB_IMP { get; set; }
public string IMP_COMM { get; set; }
public string SERV_NOM { get; set; }
public string PO_NOM { get; set; }
}
【问题讨论】: