Click here to Skip to main content
15,881,248 members
Articles / Desktop Programming / WPF
Tip/Trick

Multi selection TreeView in WPF... the easy way.

Rate me:
Please Sign up or sign in to vote.
2.67/5 (3 votes)
30 Jan 2010CPOL 27.5K   2   2
Want to use multi selection in WPF TreeView ? <Setter Property="BorderBrush"...
Want to use multi selection in WPF TreeView ?

XML
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="BorderThickness" Value="1"></Setter>
<Style.Triggers>
<Trigger  Property="c:TreeViewExtensions.IsSelected"  Value="True" >
 <Setter Property="BorderBrush" Value="Gray"></Setter>
</Trigger>
</Style.Triggers>
</Style>

...

<TreeView c:TreeViewExtensions.EnableMultiSelect="true"
c:TreeViewExtensions.SelectedItems="{Binding SelectedItems}"
ItemsSource="{Binding Items}"
... />



Code and sample on my blog[^].

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Freelance
France France
I am currently the CTO of Metaco, we are leveraging the Bitcoin Blockchain for delivering financial services.

I also developed a tool to make IaaS on Azure more easy to use IaaS Management Studio.

If you want to contact me, go this way Smile | :)

Comments and Discussions

 
GeneralReason for my vote of 1 it's bad Pin
bean_dou27-Dec-11 1:08
bean_dou27-Dec-11 1:08 
GeneralRe: what is bad ? do you have a better solution ? Pin
Nicolas Dorier27-Dec-11 1:23
professionalNicolas Dorier27-Dec-11 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.