Skip to content

Commit c9f3fd5

Browse files
committed
Clear file selection when selecting item in the pane
1 parent 33d95ad commit c9f3fd5

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/Files.App/UserControls/Pane/ShelfPane.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
Padding="8,4,8,4"
104104
CanDragItems="True"
105105
DragItemsStarting="ListView_DragItemsStarting"
106+
GotFocus="ShelfItemsList_GotFocus"
106107
ItemContainerTransitions="{x:Null}"
107108
ItemsSource="{x:Bind ItemsSource, Mode=OneWay}"
108109
RightTapped="ShelfItemsList_RightTapped"

src/Files.App/UserControls/Pane/ShelfPane.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ widgetCardItem.DataContext is not ShelfItem item ||
106106
e.Handled = true;
107107
}
108108

109+
private void ShelfItemsList_GotFocus(object sender, RoutedEventArgs e)
110+
{
111+
if (ItemFocusedCommand is not null)
112+
ItemFocusedCommand.Execute(null);
113+
}
114+
109115
public ObservableCollection<ShelfItem>? ItemsSource
110116
{
111117
get => (ObservableCollection<ShelfItem>?)GetValue(ItemsSourceProperty);
@@ -121,5 +127,14 @@ public ICommand? ClearCommand
121127
}
122128
public static readonly DependencyProperty ClearCommandProperty =
123129
DependencyProperty.Register(nameof(ClearCommand), typeof(ICommand), typeof(ShelfPane), new PropertyMetadata(null));
130+
131+
public ICommand? ItemFocusedCommand
132+
{
133+
get => (ICommand?)GetValue(ItemFocusedCommandProperty);
134+
set => SetValue(ItemFocusedCommandProperty, value);
135+
}
136+
public static readonly DependencyProperty ItemFocusedCommandProperty =
137+
DependencyProperty.Register(nameof(ItemFocusedCommand), typeof(ICommand), typeof(ShelfPane), new PropertyMetadata(null));
138+
124139
}
125140
}

src/Files.App/Views/MainPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
Margin="4,0,0,8"
274274
x:Load="{x:Bind ViewModel.ShowShelfPane, Mode=OneWay}"
275275
ClearCommand="{x:Bind ViewModel.ShelfViewModel.ClearItemsCommand}"
276+
ItemFocusedCommand="{x:Bind Commands.ClearSelection, Mode=OneWay}"
276277
ItemsSource="{x:Bind ViewModel.ShelfViewModel.Items}" />
277278
</Grid>
278279
</controls:SidebarView.InnerContent>

0 commit comments

Comments
 (0)