Click here to Skip to main content
15,901,982 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a treeview in my wpf application's xaml file
which uses a hieracialdatatemplate
so based on my Observable collection inside the viewmodel i am populating my tree view

how shall i make a treeview item visibility to false
currently i am using the visibility property to Collapsed

but i still an empty space is left inside the treeview.

How shall i totally remove the treeview item when even i want


I mean if i have
---TreeviewItem1
---TreeviewItem2
---TreeviewItem3

how shall make it
---TreeviewItem1
---TreeviewItem3
dynamically??





Thanks in advance
Arun
Posted
Updated 29-Aug-12 11:28am
v2
Comments
Kenneth Haugland 29-Aug-12 15:56pm    
Can you delete items in the observable collection? Assuming they are binded to the TreeView that should work.
Christian Amado 29-Aug-12 17:26pm    
This is very valid way :)
arun_pk 29-Aug-12 23:48pm    
Yeah removing will work . But the requirement is to keep the item in collection and make it invisible :(

You can add a Converter attached to the Visibility property of your TreeView.

Another way is to delete de item from ObservableCollection as said @Kenneth :)

Converters can slow down your performance when you have many items in your binded element.

Hope you can find it useful :)
 
Share this answer
 
v2
Comments
arun_pk 29-Aug-12 23:49pm    
I am using visibility COnvertor but it still keep a blank treeview item inbetween :(
Christian Amado 29-Aug-12 23:52pm    
Are you using hidden or collapsed? You must use collapsed.
Instead of setting property of Heirecial data template
The Visibility property shall be done for
the
HTML
<treeview.itemcontatinerstyle>
<style>
<setter property="Visibility" value="{Binding  Visibility}">
</setter></style>
</treeview.itemcontatinerstyle>
 
Share this answer
 
v2
C#
Response.write("Deepak");
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900