开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜