0
我有以下類結構和所有類實現INotifyPropertyChanged
WPF ItemsControl的數據綁定不工作
class University
{
List<Faculty> Faculties;
}
class Faculty
{
string Name;
List<Degree> Degrees;
bool IsSelected
}
class Degree
{
string Code;
List<Subject> Subjects
bool IsSelected
}
class Subject
{
string Nme;
string Code;
bool IsSelected
}
。 (小組將控制大學進行的當前課程)
我已經使用Itemcontol
這個perpose。
在我的ViewModel中我有對象Current Faculty Faculty類型。我已經將CurrentFaculty綁定到我的XAML
以下是我的XAML代碼。
<ItemsControl Grid.Column="2" Grid.Row="0" ItemsSource="{Binding CurrentFaculty, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox Margin="22,10,0,0" IsChecked="{Binding IsSelected, Mode=TwoWay}">
<TextBlock Text="All"/>
</CheckBox>
<ItemsControl Grid.Column="2" Grid.Row="0" ItemsSource="{Binding Degrees, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<CheckBox Margin="22,10,0,0" IsChecked="{Binding IsSelected, Mode=TwoWay}">
<TextBlock Text="{Binding Name, Mode=TwoWay}"/>
</CheckBox>
<ItemsControl ItemsSource="{Binding Subjects, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Margin="42,10,0,0" IsChecked="{Binding IsSelected, Mode=TwoWay}">
<TextBlock Text="{Binding Name}"></TextBlock>
</CheckBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
這是行不通的。這是什麼錯誤?
你是否檢查過任何綁定錯誤的輸出窗口? – Mark 2014-10-28 12:11:14