Létrehoztam egy Treeview és használt verem panel is egy négyzetet, ikon kép és a szöveg minden egyes levél a fában. Ezek a csomópontok jönnek létre futási időben. Nekem is van egy gomb objektumot. Az XAML alatt van.
A gondom az, hogy amikor a click me gombra kattint, meg kell áthalad keresztül a fa nézet, és ha be van jelölve, valamilyen funkciót látnak.
Tudja valaki, hogyan lehet megtudni, ha a négyzetet a csúcs a fában van jelölve, a C # kód mögött ???
<Window x:Class=WPF_Explorer_Tree.Window1
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
xmlns:local=clr-namespace:WPF_Explorer_Tree
Title=KryptoG Height=424 Width=815 Loaded=Window_Loaded>
<Window.Resources>
<local:HeaderConverter x:Key=formatter />
</Window.Resources>
<Grid>
<TreeView x:Name=foldersItem SelectedItemChanged=foldersItem_SelectedItemChanged Background=#FFFFFFFF BorderBrush=#FFFFFFFF Foreground=#FFFFFFFF Margin=0,0,236,112 AllowDrop=True Visibility=Visible>
<TreeView.Resources>
<Style TargetType={x:Type TreeViewItem}>
<Setter Property=HeaderTemplate>
<Setter.Value>
<DataTemplate>
<StackPanel Name=ST Orientation=Horizontal>
<CheckBox VerticalAlignment=Center Name=SelectedCheckBox IsChecked=False Checked=CheckBox_Checked Unchecked=CheckBox_Unchecked />
<Image Name=img Width=20 Stretch=Fill
Source={Binding
RelativeSource={RelativeSource
Mode=FindAncestor,
AncestorType={x:Type TreeViewItem}},
Path=Header,
Converter={x:Static local:HeaderToImageConverter.InstanceIcon}}
/>
<TextBlock VerticalAlignment=Center Text={Binding
RelativeSource={RelativeSource
Mode=FindAncestor,
AncestorType={x:Type TreeViewItem}},
Path=Header,
Converter={StaticResource formatter}}
/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TreeView.Resources>
</TreeView>
<TreeView HorizontalAlignment=Right Margin=0,0,12,12 Name=treeView1 Width=204 AllowDrop=True BorderBrush=White Foreground=White />
<Button Height=23 HorizontalAlignment=Left Margin=12,0,0,70 Name=button1 VerticalAlignment=Bottom Width=75 Click=button1_Click>Click Me</Button>
<Button Height=23 HorizontalAlignment=Left Margin=267,0,0,69 Name=button2 VerticalAlignment=Bottom Width=75 Click=button2_Click>Click Me too</Button>
</Grid>













