Skip to content

Commit 33f690e

Browse files
authored
Fixed delete dialog primary button focus issue (#7882)
1 parent d5baa28 commit 33f690e

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

src/Files/Dialogs/FilesystemOperationDialog.xaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@
2121
SecondaryButtonText="{x:Bind ViewModel.SecondaryButtonText, Mode=OneWay}"
2222
Style="{StaticResource DefaultContentDialogStyle}"
2323
mc:Ignorable="d">
24-
<i:Interaction.Behaviors>
25-
<!-- No need to specify CommandParameter - `e` is passed by default -->
26-
<icore:EventTriggerBehavior EventName="Loaded">
27-
<icore:InvokeCommandAction Command="{x:Bind ViewModel.LoadedCommand, Mode=OneWay}" />
28-
</icore:EventTriggerBehavior>
29-
</i:Interaction.Behaviors>
3024

3125
<ContentDialog.Resources>
3226
<ResourceDictionary>
@@ -68,13 +62,14 @@
6862
x:Load="{x:Bind ViewModel.PermanentlyDeleteLoad, Mode=OneWay}"
6963
Content="Permanently delete"
7064
IsChecked="{x:Bind ViewModel.PermanentlyDelete, Mode=TwoWay}"
71-
IsEnabled="{x:Bind ViewModel.PermanentlyDeleteEnabled, Mode=OneWay}" />
65+
IsEnabled="False" />
7266

7367
<Grid>
7468
<ListView
7569
x:Name="DetailsGrid"
7670
Grid.Row="1"
7771
MaxHeight="200"
72+
IsEnabled="False"
7873
IsItemClickEnabled="False"
7974
ItemsSource="{x:Bind ViewModel.Items}"
8075
SelectionMode="{x:Bind ViewModel.ItemsSelectionMode, Mode=OneWay}">
@@ -213,9 +208,7 @@
213208
x:Uid="ConflictingItemsDialogItemOptionReplaceExisting"
214209
Command="{Binding ReplaceExistingCommand}"
215210
Text="Replace" />
216-
<MenuFlyoutItem
217-
Command="{Binding SkipCommand}"
218-
Text="{helpers:ResourceString Name=Skip}" />
211+
<MenuFlyoutItem Command="{Binding SkipCommand}" Text="{helpers:ResourceString Name=Skip}" />
219212
</MenuFlyout>
220213
</muxc:SplitButton.Flyout>
221214
</muxc:SplitButton>

src/Files/Dialogs/FilesystemOperationDialog.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.Toolkit.Uwp.UI;
44
using System.Collections.Generic;
55
using System.Linq;
6+
using Windows.UI.Xaml;
67
using Windows.UI.Xaml.Controls;
78

89
// The Content Dialog item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
@@ -25,6 +26,24 @@ public FilesystemOperationDialog(FilesystemOperationDialogViewModel viewModel)
2526

2627
ViewModel = viewModel;
2728
ViewModel.View = this;
29+
ViewModel.LoadedCommand.Execute(null);
30+
}
31+
32+
protected override void OnApplyTemplate()
33+
{
34+
base.OnApplyTemplate();
35+
var primaryButton = this.FindDescendant("PrimaryButton") as Button;
36+
if (primaryButton != null)
37+
{
38+
primaryButton.GotFocus += PrimaryButton_GotFocus;
39+
}
40+
}
41+
42+
private void PrimaryButton_GotFocus(object sender, RoutedEventArgs e)
43+
{
44+
(sender as Button).GotFocus -= PrimaryButton_GotFocus;
45+
chkPermanentlyDelete.IsEnabled = ViewModel.PermanentlyDeleteEnabled;
46+
DetailsGrid.IsEnabled = true;
2847
}
2948

3049
private void MenuFlyoutItem_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)

0 commit comments

Comments
 (0)