RadDataGrid不在运行时更新主题

时间:2018-03-06 21:25:07

标签: uwp telerik

我正在使用“Telerik UI for Universal Windows Platform”的免费/开源版本。

我的问题是我的UWP应用程序支持深色/浅色主题,并在运行时响应RequestedTheme的更改(使用RootFrame.RequestedTheme)。但RadDataGrid不会回应它,即使我相信我已经按照here找到的文档。 RadDataGrid使用它开头的主题,但不会反映在运行时应用的更改。

我尝试使用Windows Template Studio创建一个全新的应用程序,并实现Settings,Telerik DDataataGrid和Telerik Graph。 Graph页面在运行时响应Settings.Sme更改但网格页面没有。

所以我的问题是。它对DataGrid不起作用吗?这是一个错误吗?或者我必须以另一种方式处理它?<​​/ p>

1 个答案:

答案 0 :(得分:1)

一种可行的方法是将ResourceDictionary放入Page.Resources

Page.xaml,

<Page
    ...
    xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
    xmlns:telerik="using:Telerik.UI.Xaml.Controls"
    RequestedTheme="Dark"
    mc:Ignorable="d">
    <Page.Resources>
        <ResourceDictionary>
            <telerik:UserThemeResources x:Key="themeResourceInitializer"/>
            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Default">
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="ms-appx:///Telerik.UI.Xaml.Grid.UWP/Themes/ThemeResourcesDark.xaml"/>
                        <ResourceDictionary Source="{CustomResource DarkResourcesPath}"/>
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
                <ResourceDictionary x:Key="Light">
                    <ResourceDictionary.MergedDictionaries>
                        <ResourceDictionary Source="ms-appx:///Telerik.UI.Xaml.Grid.UWP/Themes/ThemeResourcesLight.xaml"/>
                        <ResourceDictionary Source="{CustomResource LightResourcesPath}"/>
                    </ResourceDictionary.MergedDictionaries>
                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>
        </ResourceDictionary>
    </Page.Resources>

    <StackPanel>
        <telerikGrid:RadDataGrid x:Name="DataGrid" Height="600"/>
        <Button Content="change theme" Background="Orange" Click="Button_Click"/>
    </StackPanel>
</Page>

Page.xaml.cs,

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (this.RequestedTheme == ElementTheme.Light)
    {
        this.RequestedTheme = ElementTheme.Dark;
    }
    else
    {
        this.RequestedTheme = ElementTheme.Light;
    }
}
相关问题