Skip to content

Commit a7f58f5

Browse files
authored
fix(controls): Prevent keyboard focus on hidden buttons in MessageBox (#1574)
1 parent 86c127b commit a7f58f5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Wpf.Ui/Controls/MessageBox/MessageBox.xaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
<ResourceDictionary
99
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
1010
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
11-
xmlns:controls="clr-namespace:Wpf.Ui.Controls">
11+
xmlns:controls="clr-namespace:Wpf.Ui.Controls"
12+
xmlns:converters="clr-namespace:Wpf.Ui.Converters">
13+
14+
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
1215

1316
<Style TargetType="{x:Type controls:MessageBox}">
1417
<Setter Property="MaxWidth" Value="450" />
@@ -109,7 +112,10 @@
109112
CommandParameter="{x:Static controls:MessageBoxButton.Primary}"
110113
Content="{TemplateBinding PrimaryButtonText}"
111114
Icon="{TemplateBinding PrimaryButtonIcon}"
112-
IsDefault="True" />
115+
IsDefault="True"
116+
IsEnabled="{TemplateBinding IsPrimaryButtonEnabled}"
117+
Visibility="{TemplateBinding IsPrimaryButtonEnabled,
118+
Converter={StaticResource BoolToVisibilityConverter}}" />
113119

114120
<controls:Button
115121
Grid.Column="2"
@@ -118,7 +124,10 @@
118124
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:MessageBox}}, Path=TemplateButtonCommand, Mode=OneTime}"
119125
CommandParameter="{x:Static controls:MessageBoxButton.Secondary}"
120126
Content="{TemplateBinding SecondaryButtonText}"
121-
Icon="{TemplateBinding SecondaryButtonIcon}" />
127+
Icon="{TemplateBinding SecondaryButtonIcon}"
128+
IsEnabled="{TemplateBinding IsSecondaryButtonEnabled}"
129+
Visibility="{TemplateBinding IsSecondaryButtonEnabled,
130+
Converter={StaticResource BoolToVisibilityConverter}}" />
122131

123132
<controls:Button
124133
Grid.Column="4"

0 commit comments

Comments
 (0)