如何在设计器中隐藏 UserControl 的内部控件?

How to hide the inner controls of a UserControl in the Designer?(如何在设计器中隐藏 UserControl 的内部控件?)
本文介绍了如何在设计器中隐藏 UserControl 的内部控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含 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 的内部控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)