public static async Task SetRequestedThemeAsync()
{
foreach (var view in CoreApplication.Views)
{
await view.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
if (Window.Current.Content is FrameworkElement frameworkElement)
{
frameworkElement.RequestedTheme = Theme;
}
});
}
}
This is my code that correctly changes the theme of views in my app, but now I have some ContentDialogs and they don't change their theme. So in this case I wanna ask two questions:
ContentDialogs and they don't change their theme.
It's looks known issue here. please feel free vote up this report. and currently there is a workaround that set the dialog's theme when show popup like the following.
private async void Button_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
ContentDialog dialog = new ContentDialog();
dialog.Title = "Save your work?";
dialog.PrimaryButtonText = "Save";
dialog.SecondaryButtonText = "Don't Save";
dialog.CloseButtonText = "Cancel";
dialog.DefaultButton = ContentDialogButton.Primary;
dialog.Content = "Test Theme";
dialog.RequestedTheme = (Window.Current.Content as FrameworkElement).RequestedTheme;
var result = await dialog.ShowAsync();
}