Kinnara / ModernWpf

Modern styles and controls for your WPF applications
MIT License
4.45k stars 446 forks source link

How to add High contrast support to ContentDialog? #547

Open nonew opened 1 year ago

nonew commented 1 year ago

I have two questions:

  1. Build solution with VS2022 and run ModernWpf.SampleApp with .net6 will raise exception, see below screenshot:

image

  1. How to add High contrast support to ContentDialog?

I write customized ConsentDialog.xaml like this:

<ui:ContentDialog xmlns:ui="clr-namespace:ModernWpf.Controls;assembly=ModernWpf.Controls" x:Class="MyDialogApp.ConsentDialog" .... mc:Ignorable="d">

<ui:ContentDialog.Resources>
...
</ui:ContentDialog.Resources>
<ui:ContentDialog.Style>
...
</ui:ContentDialog.Style>

</ui:ContentDialog>

And show the dialog like this: public static async Task ShowAsync(string title, string content, string primaryBtnText, string secondaryBtnText) { try { Close(); _dialog = new ConsentDialog { Title = title, Content = content, PrimaryButtonText = primaryBtnText, SecondaryButtonText = secondaryBtnText }; await _dialog.ShowAsync(); } catch (Exception ex) { Logger.Error(ex.Message); } return _result; }