Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF:CustomControls与UserControls_Wpf_User Controls_Custom Controls - Fatal编程技术网

WPF:CustomControls与UserControls

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

在WPF中,CustomControls和UserControls之间有什么区别?我应该何时使用每个?

用户控件(组合):

  • 组成多个现有控件 进入一个可重用的“组”
  • 由XAML和代码隐藏组成 文件
  • 无法设置样式/模板
  • 派生自用户控件

CustomControl(扩展现有控件)

  • 使用扩展现有控件 附加功能
  • 由代码文件和默认值组成 主题/Generic.xaml中的样式
  • 可以设置样式/模板
  • 构建控件的最佳方法 图书馆

资料来源: