问题描述
我有一个包含 DropDownList 和 ObjectDataSource 的 UserControl.该控件用于我的 MasterPage 的标记中.
I have a UserControl that contains a DropDownList and an ObjectDataSource. That control is used in the markup of my MasterPage.
在使用该 MasterPage 的 ContentPage 的设计器中,我可以看到 DropDownList 和 ObjectDataSource.自己看看.
In the Designer of a ContentPage that uses that MasterPage I can see the DropDownList and the ObjectDataSource. See for yourself.
我知道其他控件(如 ComponentArt:Grid)仅将自己显示为外部容器并隐藏内部控件.
I know that other controls (like ComponentArt:Grid) only show themself as outer container and hide the inner controls.
我想这可以通过属性以某种方式实现.我必须设置哪些?
I guess that is somehow achievable with attributes. Which ones do I have to set?
推荐答案
我猜你提到的控件 ComponentArt:Grid 有一个关联的 ControlDesigner 可以做任何事情,包括设计时可编辑区域和自定义操作菜单(与右上角的箭头).
I'm guessing that the control you refer to, ComponentArt:Grid, have an associated ControlDesigner which can do about anything, including designtime editable areas and custom action menus (the menu associated with the arrow in the upper right corner).
但是,Visual Studio [上次我尝试过] 没有为 UserControls 执行控件设计器,因此您无法轻松控制它.UserControlDesigner 的后台发生了很多神奇的事情,包括解析 html 代码.但是,我从未见过代码隐藏文件的实际编译,其中会指定 ControlDesigner 属性.
However, Visual Studio does not [last time I tried] execute the control designer for UserControls, so you can not easily control this. There's a lot of magic happening in the background in the UserControlDesigner including parsing the html code. However, I've never seen actual compilation of the codebehind file, where the ControlDesigner attribute would be specified.
您需要将控件重写为 Visual Studio 的服务器控件以检查属性,并允许自定义设计时视图.
You will need to rewrite your control as a server control for Visual Studio to check for the attribute, and allowing your custom designtime view.
这篇关于如何在设计器中隐藏 UserControl 的内部控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!