[英]Binding collection of collection to datagrid source in WPF MVVM Model
我有以下結構的視圖模型:
Viewmodel:
public System SystemLst
{
get;set;
}
模型:
public class System
{
public ObservableCollection<Properties> PropertySource
{
get { return _dutPropertiesColl; }
set {
_dutPropertiesColl = value;
NotifyPropertyChanged("DUTPropertySource");
}
}
public ObservableCollection<SubSystem> SubSystemList
{
get { return _subSystemList; }
set
{
_subSystemList = value;
NotifyPropertyChanged("SubsystemList");
}
}
}
public SubSystem SubSystemList
{
public ObservableCollection<Test> TestLists
{
get;
set;
}
}
我有一個WPF表單,並將datacontext設置為視圖模型。 還有一個形式為datagrid的數據網格,其itemsource應該設置為TestLists。 我嘗試了以下操作,但不起作用:
<DataGrid Name="dgList" ItemsSource="{Binding Systemlst.SubSystemList.TestLists}" Grid.Row="0" Margin="0,0,0,0"
CanUserAddRows="False" AutoGenerateColumns="False" IsReadOnly="True" >
我該如何實現?
您的ViewModel應該是公共訪問類型的簡單類。 視圖模型應該具有ObservableCollection SubSystemList,它將充當ItemSource。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.