【问题标题】:What is the difference between wpf custom control library and wpf class Librarywpf自定义控件库和wpf类库有什么区别
【发布时间】:2014-06-11 02:42:42
【问题描述】:

WPF自定义控件库和wpf类库的基本区别是什么。我想了解一下dll和架构角度的区别。因为自定义控件本身就是一个类,而WPF类库也是包含类的.但是自定义控件类在 wpf 类库中不起作用。

【问题讨论】:

标签: wpf custom-controls class-library


【解决方案1】:

您可以将 WPF 自定义控件库视为具有更多配置的简单类库:

ThemeInfo 程序集属性:

[assembly:ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
                         //(used if a resource is not found in the page, 
                         // or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
                                  //(used if a resource is not found in the page, 
                                  // app, or any theme specific resource dictionaries)

)]

上述属性指定在哪里寻找控件的默认样式/模板。您可以从上面的 cmets 中获得 ResourceDictionaryLocation.SourceAssembly 所做的事情,SourceAssembly 中搜索 Resources 的默认位置是特殊路径 Themes/Generic.xaml,这是在添加新的 WPF 自定义控件库时默认创建的。

您可以手动添加这些并将类库转换为 WPF 自定义控件库。

如果没有ThemeInfo 属性,默认样式/模板只会在应用程序资源字典中搜索,如果没有,则会出现错误。这就是为什么CustomControls 通常不适用于类库。

【讨论】:

  • 谢谢。它对我来说非常有用。
猜你喜欢
  • 1970-01-01
  • 2010-10-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多