Skip to content

Commit 3438bed

Browse files
committed
Switched to DoubleClick Event for DataGrid Items
1 parent 69a015b commit 3438bed

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

GenericFileBrowser.xaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,23 @@
149149

150150
<Grid Padding="50,200,50,0">
151151

152-
<controls:DataGrid x:FieldModifier="public" x:Name="AllView" Drop="AllView_DropAsync" AutoGenerateColumns="False" CanDrag="False" AllowDrop="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" SelectionMode="Single" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Margin="0,0,0,0" Padding="0, 0, 0, 0" HorizontalAlignment="Left">
153-
152+
<controls:DataGrid FocusVisualPrimaryThickness="0" SelectionMode="Single" IsDoubleTapEnabled="True" x:FieldModifier="public" x:Name="AllView" Drop="AllView_DropAsync" AutoGenerateColumns="False" CanDrag="False" AllowDrop="True" DragOver="AllView_DragOver" IsRightTapEnabled="True" CanUserReorderColumns="False" IsReadOnly="True" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Margin="0,0,0,0" Padding="0, 0, 0, 0" HorizontalAlignment="Left">
153+
154154
<controls:DataGrid.Resources>
155+
<MenuFlyout x:Name="HeaderRightClickMenu" x:Key="HeaderRightClickFlyout">
156+
<MenuFlyoutItem Text="Edit Columns" Name="EditColumn">
157+
<MenuFlyoutItem.Icon>
158+
<FontIcon Glyph="&#xE70F;"/>
159+
</MenuFlyoutItem.Icon>
160+
</MenuFlyoutItem>
161+
<MenuFlyoutItem Text="Size All Columns to Fit" Name="FitColumns">
162+
<MenuFlyoutItem.Icon>
163+
<FontIcon Glyph="&#xE9A6;"/>
164+
</MenuFlyoutItem.Icon>
165+
</MenuFlyoutItem>
166+
</MenuFlyout>
155167

156-
157-
<MenuFlyout x:Name="RightClickContextMenu" x:Key="RightClickFlyout">
168+
<MenuFlyout x:Name="RightClickContextMenu" x:Key="RightClickFlyout">
158169
<MenuFlyout.Items>
159170
<MenuFlyoutItem Text="Open" Name="OpenItem">
160171
<MenuFlyoutItem.Icon>

GenericFileBrowser.xaml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public sealed partial class GenericFileBrowser : Page
3535
public TextBlock textBlock;
3636
public static DataGrid data;
3737
public static MenuFlyout context;
38+
public static MenuFlyout HeaderContextMenu;
3839

3940
public GenericFileBrowser()
4041
{
@@ -54,6 +55,7 @@ public GenericFileBrowser()
5455
ItemViewModel.PVIS.isVisible = Visibility.Collapsed;
5556
data = AllView;
5657
context = RightClickContextMenu;
58+
HeaderContextMenu = HeaderRightClickMenu;
5759
Interact.Interaction.page = this;
5860
OpenItem.Click += Interact.Interaction.OpenItem_Click;
5961
ShareItem.Click += Interact.Interaction.ShareItem_Click;
@@ -66,10 +68,12 @@ public GenericFileBrowser()
6668
Back.Click += Navigation.NavigationActions.Back_Click;
6769
Forward.Click += Navigation.NavigationActions.Forward_Click;
6870
Refresh.Click += Navigation.NavigationActions.Refresh_Click;
69-
AllView.SelectionChanged += Interact.Interaction.List_ItemClick;
71+
AllView.DoubleTapped += Interact.Interaction.List_ItemClick;
7072

7173
}
7274

75+
76+
7377
public static UniversalPath p = new UniversalPath();
7478
public static UniversalPath P { get { return GenericFileBrowser.p; } }
7579

@@ -152,6 +156,8 @@ private void Button_Click(object sender, RoutedEventArgs e)
152156
{
153157
ProgressBox.Visibility = Visibility.Collapsed;
154158
}
159+
160+
155161
}
156162

157163
public class EmptyFolderTextState : INotifyPropertyChanged

ItemInteractions.cs

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,17 @@ public Interaction(Page p)
4646

4747

4848

49-
public static async void List_ItemClick(object sender, SelectionChangedEventArgs e)
49+
public static async void List_ItemClick(object sender, DoubleTappedRoutedEventArgs e)
5050
{
5151
if (page.Name == "GenericItemView")
5252
{
53+
54+
var index = GenericFileBrowser.data.SelectedIndex;
5355

54-
55-
if (e.AddedItems.Count == 1)
56+
if(index > -1)
5657
{
57-
var index = GenericFileBrowser.data.SelectedIndex;
5858
var clickedOnItem = ItemViewModel.FilesAndFolders[index];
5959

60-
6160
if (clickedOnItem.FileExtension == "Folder")
6261
{
6362
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
@@ -75,8 +74,13 @@ public static async void List_ItemClick(object sender, SelectionChangedEventArgs
7574
options.DisplayApplicationPicker = true;
7675
await Launcher.LaunchFileAsync(file, options);
7776
}
78-
7977
}
78+
else
79+
{
80+
// Placeholder for row sorting logic
81+
}
82+
83+
8084
}
8185

8286
}
@@ -118,8 +122,20 @@ public static async void PhotoAlbumItemList_ClickAsync(object sender, ItemClickE
118122

119123
public static void AllView_RightTapped(object sender, RightTappedRoutedEventArgs e)
120124
{
125+
126+
121127
DataGrid dataGrid = (DataGrid)sender;
122-
GenericFileBrowser.context.ShowAt(dataGrid, e.GetPosition(dataGrid));
128+
129+
// If user clicks on header
130+
if(dataGrid.CurrentColumn == null)
131+
{
132+
GenericFileBrowser.HeaderContextMenu.ShowAt(dataGrid, e.GetPosition(dataGrid));
133+
}
134+
// If user clicks on actual row
135+
else
136+
{
137+
GenericFileBrowser.context.ShowAt(dataGrid, e.GetPosition(dataGrid));
138+
}
123139

124140
}
125141

MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</Page.Resources>
3030
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
3131

32-
<Grid Tag="{x:Bind Tag, Mode=OneWay}" Background="Transparent" Name="DragArea" HorizontalAlignment="Left" Height="34" VerticalAlignment="Top" Width="1689" Margin="55,0,0,0" Canvas.ZIndex="5"/>
32+
<Grid Tag="{x:Bind Tag, Mode=OneWay}" Background="Transparent" Name="DragArea" HorizontalAlignment="Stretch" Height="34" VerticalAlignment="Top" Margin="55,0,200,0" Canvas.ZIndex="5"/>
3333

3434
<NavigationView SelectedItem="{x:Bind local:MainPage.Select.itemSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" x:FieldModifier="public" AlwaysShowHeader="False" IsPaneOpen="True" Loaded="navView_Loaded" IsBackButtonVisible="Collapsed" IsSettingsVisible="True" x:Name="navView" SelectionChanged="navView_ItemSelected" VerticalAlignment="Stretch" >
3535

0 commit comments

Comments
 (0)