Silverlight 工具包 - 带主题的 ChildWindow

发布于 2024-11-03 22:41:17 字数 573 浏览 5 评论 0原文

从我发现的 silverlight 论坛页面来看,我的印象是在后面的代码中创建的 ChildWindow 会选取页面其余部分的主题;只有当您继承自ChildWindow时,情况就不再是这样了。

出于某种原因,尽管这不会发生在我身上。这是我的主题元素:

<wp:Theme x:Name="ThemeContainer" ThemeUri="/System.Windows.Controls.Theming.BubbleCreme;component/Theme.xaml"> 

这是我用来尝试创建 ChildWindow 的按钮的事件处理程序。弹出窗口,但没有应用任何主题:

    private void Button_Click(object sender, RoutedEventArgs e) {
        ChildWindow cw = new ChildWindow() { Height = 250, Width = 200 };
        cw.Show();
    }

有什么方法可以让它工作吗?

From a silverlight forum page I found, I was under the impression that a ChildWindow created in the code behind would pick up the theme of the rest of the page; it's only when you inherit from ChildWindow that this no longer is the case.

For some reason though this is not happening for me. Here is my theme element:

<wp:Theme x:Name="ThemeContainer" ThemeUri="/System.Windows.Controls.Theming.BubbleCreme;component/Theme.xaml"> 

And here's the event handler for a button that I'm using to try to create a ChildWindow. The window pops up, but does not have any theme applied:

    private void Button_Click(object sender, RoutedEventArgs e) {
        ChildWindow cw = new ChildWindow() { Height = 250, Width = 200 };
        cw.Show();
    }

Is there any way to get this to work?

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

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

发布评论

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

评论(1

极致的悲 2024-11-10 22:41:17

您必须在 App.xaml 中设置所需的全局主题并将其声明为应用程序的主题:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="MyApp"
             xmlns:thm="MyThemeNamespace"
             thm:MyTheme.IsApplicationTheme="True"
             >
    <Application.Resources>

    </Application.Resources>
</Application>

要动态设置应用程序主题,您可以尝试静态

Theme.SetApplicationThemeUri(myApp, myThemeUri);

You'll have to set your desired global theme in the App.xaml and declare it as the Application's theme:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="MyApp"
             xmlns:thm="MyThemeNamespace"
             thm:MyTheme.IsApplicationTheme="True"
             >
    <Application.Resources>

    </Application.Resources>
</Application>

To set the application theme dynamically, you can try the static

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