如何在listbox数据模板WPF中绑定列表视图
我有一个名为letter的类,它包含一组对象,但当我将项源绑定到列表框时,listview数据模板中的components对象的属性为空 XAML如何在listbox数据模板WPF中绑定列表视图,wpf,Wpf,我有一个名为letter的类,它包含一组对象,但当我将项源绑定到列表框时,listview数据模板中的components对象的属性为空 XAML <Window.Resources> <DataTemplate x:Key="lstDTGame"> <WrapPanel Height="30"> <TextBlock Text="{Binding Name}"></TextBlock>
<Window.Resources>
<DataTemplate x:Key="lstDTGame">
<WrapPanel Height="30">
<TextBlock Text="{Binding Name}"></TextBlock>
<ListView></ListView>
<ListView ItemsSource="{Binding Path=Component}">
<ListView.View>
<GridView AllowsColumnReorder="True"
ColumnHeaderToolTip="Employee Information">
<GridViewColumn Header="{Binding Path=Name}"
Width="100"
DisplayMemberBinding="{Binding Path=Point}" />
</GridView>
</ListView.View>
</ListView>
</WrapPanel>
</DataTemplate>
</Window.Resources>
课程
public class Letter
{
public long ID { get; set; }
public string Name { get; set; }
public string Value { get; set; }
public int Total { get; set; }
public ObservableCollection<Component> Components { get; set; }
}
公开课信函
{
公共长ID{get;set;}
公共字符串名称{get;set;}
公共字符串值{get;set;}
公共整数总计{get;set;}
公共ObservableCollection组件{get;set;}
}
3.检查DataContext是否正确设置。还要在Letter类中添加INotifyPropertyChanged,并在组件集合中添加OnPropertyChanged事件。我认为(2)是主要问题。典型检查调试输出窗口中的绑定错误条目。