开发者

How can i bind a IsSelected Property to a textblock

开发者 https://www.devze.com 2023-04-02 19:07 出处:网络
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\".

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

精彩评论

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