Creating container usercontrol with design time su

2019-06-13 19:21发布

I want to create a container usercontrol with design time support in WPF ? How can I do ?

2条回答
萌系小妹纸
2楼-- · 2019-06-13 20:06

Declare the following in your UserControl at the top:

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]  
public partial class ExpanderControl : UserControl 

Required NameSpaces:

using System.ComponentModel;
using System.ComponentModel.Design;
查看更多
迷人小祖宗
3楼-- · 2019-06-13 20:21

If you want to have a container user control with design time support, you can create a ContentControl http://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol.aspx to host other user controls inside your container control.

You can expose the content control as a public property and then assign any other user controls you create to this property to display within the ContentControl. You would have the design time support of the parent control or any child user controls by default since they would all just be user controls.

查看更多
登录 后发表回答