WPF:CustomControls与UserControls
在WPF中,CustomControls和UserControls之间有什么区别?我应该何时使用每个?用户控件(组合):WPF:CustomControls与UserControls,wpf,user-controls,custom-controls,Wpf,User Controls,Custom Controls,在WPF中,CustomControls和UserControls之间有什么区别?我应该何时使用每个?用户控件(组合): 组成多个现有控件 进入一个可重用的“组” 由XAML和代码隐藏组成 文件 无法设置样式/模板 派生自用户控件 CustomControl(扩展现有控件) 使用扩展现有控件 附加功能 由代码文件和默认值组成 主题/Generic.xaml中的样式 可以设置样式/模板 构建控件的最佳方法 图书馆 资料来源:
- 组成多个现有控件 进入一个可重用的“组”
- 由XAML和代码隐藏组成 文件
- 无法设置样式/模板
- 派生自用户控件
CustomControl(扩展现有控件)
- 使用扩展现有控件 附加功能
- 由代码文件和默认值组成 主题/Generic.xaml中的样式
- 可以设置样式/模板
- 构建控件的最佳方法 图书馆
资料来源: