WPF-UserControl的默认Content属性 [英] WPF - UserControl default Content attribute

查看:137
本文介绍了WPF-UserControl的默认Content属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个UserControl,但我只是不记得要用来装饰要用作默认内容属性的属性的属性名称.

I'm creating a UserControl and I just can't remember the name of the attribute which you use to decorate the property which you want to act as the default content property.

举一个具体的例子,假设我有一个名为标题"的属性,可以使用这样的属性语法进行设置-

To give a concrete example, say i have a property called 'Title' which i can set using property syntax like this -

<local:myControl Title="the title"/>

但是控件的使用者可能想要使用这样的元素语法-

But the consumer of the control may want to use element syntax like this -

<local:myControl> the Title </local:myControl>

我知道有一个属性,我需要将其添加到Title属性以启用此支持,但我忘记了它的含义,并且在任何地方都找不到.

I KNOW there is an attribute which I need to add to the Title property with to enable this support but I've forgotten what it is and can't find it anywhere.

有人能为我刷新我的记忆吗?另外,我正在寻找一个类似的属性,以对从ItemsControl继承的CustomControl起作用.

Could anyone refresh my memory for me? Also, I'm looking for a similar attribute to act on CustomControls inheriting from ItemsControl.

推荐答案

ContentPropertyAttribute

这篇关于WPF-UserControl的默认Content属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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