0
我想創建使用WPF樹的父子結構。WPF樹父子插入:
Tree
->Parent
->Child
->Grand Child.
我已經寫了下面的代碼,這是不能爲孩子插入。請幫我解決這個問題。
<Window x:Class="NewTree_DynamicNode.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TreeView Name="treeFileSystem" TreeViewItem.Expanded="treeFileSystem_Expanded_1">
<TreeViewItem Header="Categories" x:Name="_ImageTree" Tag="hi"
x:FieldModifier="private">
<TreeViewItem TextBlock.FontStyle="Italic"
Header="Loading..." Name="treeFileSystem2"/>
</TreeViewItem>
</TreeView>
</Grid>
</Window>
private void treeFileSystem_Expanded_1(object sender, RoutedEventArgs e)
{
this._ImageTree = (TreeViewItem)e.OriginalSource;
this._ImageTree.Items.Clear();
try
{
for(int i=0 ; i<2; i++)
{
TreeViewItem temp = new TreeViewItem();
TreeViewItem temp1 = new TreeViewItem();
temp.Header = "Parent";
temp1.Header = "Child";
temp.Items.Add(temp1);
this._ImageTree.Items.Add(temp);
}
}
catch
{
/////
}
}
嗨dean:當我點擊我的樹時,它應該與父母打開,當我點擊父母它應該打開與孩子等....我想要下面的樹結構樹--->父---->孩子-----> GrandChild – vrbilgi 2010-11-30 10:49:58