UWP 在弹出窗口中更改主题 MVVM Light

UWP Change theme in pop ups MVVM Light

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;
                    }
                });
            }
        }

这是我的代码,可以正确更改应用程序中视图的主题,但现在我有一些 ContentDialogs,它们不会更改它们的主题。 所以在这种情况下我想问两个问题:

  1. 我在静态完整属性中满足我的弹出窗口。这是一个好的决定还是每次都创建一个新的弹出对象会更好?
  2. 如果静态属性是一个不错的决定,如何更改其中的主题?

ContentDialogs and they don't change their theme.

它看起来是已知问题 here。请随时投票赞成这份报告。目前有一种变通方法可以在显示弹出窗口时设置对话框的主题,如下所示。

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();

}