How can i bind a IsSelected Property to a textblock
my treeview is populated with textblock items. If a user clicks on a textblock, i want to set a property in my model calle开发者_如何学JAVAd "isSelected". But : the textblock have no Property IsSelected. How can i Implement this ? Derive from textblock and add a Property ?
You have to use the TreeViewItem.IsSelected property. You will have to specify the custom style for all items of the tree view.
<TreeView>
<TreeView.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected}"/>
</Style>
</TreeView.Resources>
</TreeView>
精彩评论