将 WPF 主题强制应用到 .net 4.0 中的应用程序

发布于 2024-10-22 02:21:32 字数 349 浏览 3 评论 0原文

我试图通过使用以下语句强制 WPF 应用程序使用经典 Windows 主题

<ResourceDictionary Source="/PresentationFramework.Classic;V3.0.0.0;31bf3856ad364e35;component/themes/classic.xaml" />

这曾经在 .net 3.5 中正常工作。但是一旦我切换到.net 4.0,这似乎就不起作用了。谁能告诉我如何让它在 4.0 框架中工作。我尝试用PresentationFramework.Classic.dll的值替换版本号和公钥令牌,但我的努力变得徒劳......任何人都可以给我建议吗?

I was trying to force the WPF application to use the classic windows theme by using the following statement

<ResourceDictionary Source="/PresentationFramework.Classic;V3.0.0.0;31bf3856ad364e35;component/themes/classic.xaml" />

This used to work fine with .net 3.5. But once i switched to .net 4.0 this doesn't seem to work. Can anyone tell me how i can get this working in 4.0 framework. I tried replacing the version numbers and the public key tokens with the PresentationFramework.Classic.dll's values but my efforts turned futile... Can anyone suggest me something?

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

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

发布评论

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

评论(1

篱下浅笙歌 2024-10-29 02:21:32

您不需要设置版本号。您可以简单地使用它,就像

对于经典:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Classic;component/themes/classic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<Grid>
    <Button Width="120" Height="24"/>
</Grid>

对于 Royale:

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/PresentationFramework.Royale;component/themes/royale.normalcolor.xaml" />
    </ResourceDictionary.MergedDictionaries>

在引用程序集后,还必须将“复制本地”属性设置为 true。默认情况下我只有 Aero2,我将其替换为 Classic,但直到我将 copy local 设置为 true 后它才起作用。

You don't need to set the version number. You can simply use it like

For Classic:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Classic;component/themes/classic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<Grid>
    <Button Width="120" Height="24"/>
</Grid>

For Royale:

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/PresentationFramework.Royale;component/themes/royale.normalcolor.xaml" />
    </ResourceDictionary.MergedDictionaries>

The "Copy Local" property must also be set to true on the assembly after it's referenced. By default I had only Aero2, I replaced it with Classic, but it didn't work until I set copy local to true.

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