Silverlight 程序集中的资源字典?

发布于 2024-09-28 04:31:12 字数 375 浏览 2 评论 0原文

我刚刚开始尝试将一组控件组合在一起作为程序集,并且正在研究默认样式。我目前拥有的是项目中的 UserControl(感谢 Reed!),我可以通过引用将其引入另一个项目。我计划随着时间的推移添加更多控件来构建 SDK。

我目前有一些挂钩在托管应用程序中查找资源,这些挂钩要么将资源应用于各自的属性,要么通过硬编码默认值设置控件的样式。

是否可以在包含 UserControls 的项目中设置资源字典,以便他们可以使用这些引用作为默认值,而不是硬编码?如果是这样,我该如何瞄准他们?

(我在与控件相同的项目中设置了一个 ResourceDictionary:Resources>Dictionaries>Colors.xaml)

提前致谢!

I've just begun dabbling in putting together a set of controls as assemblies and I'm working on default styling. What I currently have is a UserControl in a project (thanks Reed!) and I'm able to bring that into another project via reference. I plan to add more controls over time to build something of an SDK.

I currently have some hooks that look for resources in the hosting application which either apply the resources to their respective properties, or style out the control via hard coded defaults.

Is it possible to set up resource dictionaries within the project containing the UserControls so they can use those references as the default, instead of hard coding? If so, how do I target them?

(I have a ResourceDictionary set up within the same project as the controls: Resources>Dictionaries>Colors.xaml)

Thanks in advance!

E

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

温暖的光 2024-10-05 04:31:12

您应该真正考虑在库中创建自定义模板控件,而不是 UserControls 的派生类。这将允许引用您的库的项目为您的控件指定替代的默认样式,就像我们为 Microsoft 自己的 SDK 中的控件所做的那样。

通过创建 ControlTemplate 来创建新控件 主题是一个很好的开始。

You should really look at creating custom templated controls in library rather than derivatives of UserControls. This will allow projects that reference your library to specify an alternative default style for you controls in the same way as we can for the controls in Microsofts own SDK.

The Creating a New Control by Creating a ControlTemplate topic on MSDN is good starter.

半寸时光 2024-10-05 04:31:12

我认为这是一个更好的解释,但我正在尝试桌面应用程序,但遇到了同样的问题。

XamlParseException:无法从文本“local:CustomerEntity”创建“System.Type”

I think this is a better explanation, but i'm trying on a desktop application and i got the same problem.

XamlParseException: Failed to create a 'System.Type' from the text 'local:CustomerEntity'

×纯※雪 2024-10-05 04:31:12

如果我理解正确,您想在“主题”文件夹中创建文件“generic.xaml”。但是,我不认为自动样式仅适用于 UserControlControl。一般来说,如果您尝试创建一个可以风格化和重新模板化的控件,您希望继承 Control 而不是 UserControl

If I'm undestanding correctly you want to create the file "generic.xaml" in the folder "Themes". However, I don't believe automatic styling works with UserControl only with Control. Generally if you trying to make a control that can be stylized and retemplated you want to inherit from Control and not UserControl.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文