如何在我自己的TreeViewItem上显示选择? WPF [英] How to show selection on my own TreeViewItem? WPF

查看:62
本文介绍了如何在我自己的TreeViewItem上显示选择? WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了自己的TreeViewItem并覆盖MeasureOverride,ArrangeOverride,VisualChildrenCount,GetVisualChild,LogicalChildren:


I wrote my own TreeViewItem and override MeasureOverride, ArrangeOverride, VisualChildrenCount, GetVisualChild, LogicalChildren:


public class MyTreeViewItem : TreeViewItem
{

MyControl myControl = new MyControl() // MyControl includes TextBlock 

public MyTreeViewItem ()
{
this.AddLogicalChild(myControl);
this.AddVisualChild(myControl);

}
//...
}



当我将此项目添加到TreeView项目集合中时,它可以正确显示,并且无需任何操作即可完成我想要的操作.当我单击项目时,它会升起OnSelected,但不会显示在选择项目框架中.如果我使用
control.OverridesDefaultStyle = true,它仅显示没有框架的白色文本.如何从选择视图的项目继承到该项目的子控件?还是您知道其他更好的方法来在我的控件上显示选择内容?



When I add this item to TreeView items collection it shows correctly and do what I want without one thing. When I click on item it rise OnSelected but it doesn''t show in selection item frame. If I use
control.OverridesDefaultStyle = true it shows only white text without frame. How can I inherit from item my selection view to my child control in this item? Or do you know other, better way to show selection on my control?

推荐答案

我想这时您需要使用此事件来在控件周围绘制自己的框项目.
I imagine at this point you need to use this event to draw your own box around the item.


这篇关于如何在我自己的TreeViewItem上显示选择? WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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