2
我有一個數據源:WPF:綁定的TreeView
private List<PlayData> _treeData = new List<PlayData>();
private void Test()
{
_treeData.Add(new PlayData()
{
BoolList = new List<bool>() { true, false, true },
Name = "A"
});
_treeData.Add(new PlayData()
{
BoolList = new List<bool>() { true, false, true },
Name = "B"
});
DataContext = this;
}
如何綁定這XAML,這樣的名字是父母和布爾的名單是孩子。我嘗試了這一點unsuccesfully:
<TreeView x:Name="treeView" Height="200" ItemsSource="{Binding Path=TreeData}" >
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=BoolList, Mode=TwoWay}" >
<TextBlock FontWeight="Bold" Text="{Binding Path=Name, Mode=TwoWay}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
你是什麼意思「不成功」? – 2010-12-08 12:05:55