Skip to content

Commit 33d95ad

Browse files
committed
Code Quality: Fixed Shelf context menu
1 parent bf553f0 commit 33d95ad

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
DragItemsStarting="ListView_DragItemsStarting"
106106
ItemContainerTransitions="{x:Null}"
107107
ItemsSource="{x:Bind ItemsSource, Mode=OneWay}"
108+
RightTapped="ShelfItemsList_RightTapped"
108109
ScrollViewer.VerticalScrollBarVisibility="Auto"
109110
ScrollViewer.VerticalScrollMode="Auto"
110111
SelectionMode="Extended">
@@ -126,16 +127,6 @@
126127
TextTrimming="CharacterEllipsis"
127128
TextWrapping="NoWrap"
128129
ToolTipService.ToolTip="{x:Bind Path, Mode=OneWay}" />
129-
130-
<Grid.ContextFlyout>
131-
<MenuFlyout>
132-
<MenuFlyoutItem Command="{x:Bind RemoveCommand}" Text="{helpers:ResourceString Name=RemoveFromShelf}">
133-
<MenuFlyoutItem.Icon>
134-
<FontIcon Glyph="&#xE738;" />
135-
</MenuFlyoutItem.Icon>
136-
</MenuFlyoutItem>
137-
</MenuFlyout>
138-
</Grid.ContextFlyout>
139130
</Grid>
140131
</DataTemplate>
141132
</ListView.ItemTemplate>

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

+20
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ private void ListView_DragItemsStarting(object sender, DragItemsStartingEventArg
8686
dataObjectProvider.SetDataObject(ppDataObject);
8787
}
8888

89+
private void ShelfItemsList_RightTapped(object sender, Microsoft.UI.Xaml.Input.RightTappedRoutedEventArgs e)
90+
{
91+
if (e.OriginalSource is not Microsoft.UI.Xaml.FrameworkElement widgetCardItem ||
92+
widgetCardItem.DataContext is not ShelfItem item ||
93+
item.Path is null)
94+
return;
95+
96+
var menuFlyout = new MenuFlyout();
97+
98+
menuFlyout.Items.Add (new MenuFlyoutItem
99+
{
100+
Text = Strings.RemoveFromShelf.GetLocalizedResource(),
101+
Icon = new FontIcon { Glyph = "\uE738" },
102+
Command = new RelayCommand(item.Remove)
103+
});
104+
105+
menuFlyout.ShowAt(widgetCardItem);
106+
e.Handled = true;
107+
}
108+
89109
public ObservableCollection<ShelfItem>? ItemsSource
90110
{
91111
get => (ObservableCollection<ShelfItem>?)GetValue(ItemsSourceProperty);

0 commit comments

Comments
 (0)