<Application x:Class="TreeNavigatorRequestedTheme.App" xmlns:local="using:TreeNavigatorRequestedTheme" RequestedTheme="Dark"> </Application> |
<Page.DataContext> <local:TreeViewModel></local:TreeViewModel> </Page.DataContext> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <navigation:SfTreeNavigator ItemsSource="{Binding Models}" Width="500"> <navigation:SfTreeNavigator.ItemTemplate> <primitives:HierarchicalDataTemplate ItemsSource="{Binding Models}"> <DataTemplate> <TextBlock Text="{Binding Header}"/> </DataTemplate> </primitives:HierarchicalDataTemplate> </navigation:SfTreeNavigator.ItemTemplate> </navigation:SfTreeNavigator> </Grid> |
Hi,
thanks.
The problem I have now is when switching themes dynamically.
The concept is from the Microsoft Template Studio , where one can easily switch between the Dark and Light theme on the fly.
I have tried to make the SfTreeNavigator to adhere to that, but to no avail.
Attached is a simple sample, a SfTreeNavigator is placed on the BlankPage.xaml (the very same as in the sample you provided).
In the BlankPage.xaml.cs, I subscribe to the ThemeSelectorService.OnThemeChanged event:
private void ThemeSelectorService_OnThemeChanged(object sender, Windows.UI.Xaml.ElementTheme e)
{
treeNavigator.RequestedTheme = e;
}
But it doesn't switch the theme.
Any ideas?
Thanks,
Magnus