WPF自定义控件库和wpf类库之间的基本区别是什么?我想了解从动态链接库和体系结构的角度来看,.Because自定义控件本身是一个类,WPF类库也包含class.But自定义控件类,wpf类库中不工作。
发布于 2014-04-25 12:17:23
您可以将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))]
上面的属性指定在何处查找控件的默认样式/模板。您可以从上面的注释中获得ResourceDictionaryLocation.SourceAssembly所做的操作,在SourceAssembly中搜索Resources的默认位置是在添加新的WPF自定义控件库时默认创建的特殊路径Themes/Generic.xaml。
您可以手动添加这些内容,并将类库转换为WPF自定义控件库。
没有ThemeInfo属性,默认样式/模板只在应用程序资源字典中搜索,如果没有,您将得到一个错误。这就是为什么CustomControls最常不使用类库的原因。
https://stackoverflow.com/questions/23292187
复制相似问题