Treeview项目可见性更改(动态) [英] Treeview item Visibility change (Dynamically)

查看:195
本文介绍了Treeview项目可见性更改(动态)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在wpf应用程序的xaml文件中有一个树状视图
使用hieracialdatatemplate
所以根据我在viewmodel中的Observable集合,我正在填充树视图

我如何使Treeview项目的可见性变为false
目前,我正在使用能见度属性来折叠

但我在树视图中仍然留有空白.

我什至要如何完全删除treeview项


我的意思是如果我有
--- TreeviewItem1
--- TreeviewItem2
--- TreeviewItem3

怎么做
--- TreeviewItem1
--- TreeviewItem3
动态地??





在此先感谢
Arun

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

推荐答案

您可以在 TreeView的 Visibility 属性中添加一个转换器. b>.

另一种方法是从ObservableCollection中删除de item,如@Kenneth :)

当绑定的元素中有很多项目时,转换器会降低的性能.

希望您会发现它有用:)
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 :)


而不是设置Heirecial数据模板的属性
可见性属性应用于

Instead of setting property of Heirecial data template
The Visibility property shall be done for
the
<treeview.itemcontatinerstyle>
<style>
<setter property="Visibility" value="{Binding  Visibility}">
</setter></style>
</treeview.itemcontatinerstyle>


Response.write("Deepak");


这篇关于Treeview项目可见性更改(动态)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆