I want to create a container usercontrol with design time support in WPF ? How can I do ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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;