WPF树视图中的SelectedItem数据绑定
SelectedItem
<TreeView ItemsSource="{Binding Path=Model.Clusters}" ItemTemplate="{StaticResource ClusterTemplate}" SelectedItem="{Binding Path=Model.SelectedCluster}" />
SelectedItem
“SelectedItem”属性是只读的,不能从标记中设置。
编辑:
<TreeView ItemsSource="{Binding Path=Model.Clusters}" ItemTemplate="{StaticResource HoofdCLusterTemplate}" SelectedItemChanged="TreeView_OnSelectedItemChanged" />
private void TreeView_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e){ Model.SelectedCluster = (Cluster)e.NewValue;}
慕尼黑8549860
海绵宝宝撒