Skip to content

Commit f36d40e

Browse files
authored
Fix selection options (#4227)
1 parent ccb64cf commit f36d40e

File tree

2 files changed

+21
-41
lines changed

2 files changed

+21
-41
lines changed

Files/Views/ModernShellPage.xaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@
248248
x:FieldModifier="public"
249249

250250
MultiselectEnabled="{x:Bind InteractionViewModel.MultiselectEnabled, Mode=TwoWay}"
251-
SelectAllInvokedCommand="{x:Bind SelectAllContentPageItemsCommand}"
252-
InvertSelectionInvokedCommand="{x:Bind InvertContentPageSelctionCommand}"
253-
ClearSelectionInvokedCommand="{x:Bind ClearContentPageSelectionCommand}"
251+
SelectAllInvokedCommand="{x:Bind SelectAllContentPageItemsCommand, Mode=OneWay}"
252+
InvertSelectionInvokedCommand="{x:Bind InvertContentPageSelctionCommand, Mode=OneWay}"
253+
ClearSelectionInvokedCommand="{x:Bind ClearContentPageSelectionCommand, Mode=OneWay}"
254254

255255
LayoutModeInformation="{x:Bind FolderSettings.LayoutModeInformation, Mode=OneWay}"
256256
ToggleLayoutModeDetailsView="{x:Bind FolderSettings.ToggleLayoutModeDetailsView}"
@@ -269,13 +269,13 @@
269269
IsMultiPaneActive="{x:Bind IsMultiPaneActive, Mode=OneWay}"
270270
IsPageMainPane="{x:Bind IsPageMainPane, Mode=OneWay}"
271271
IsPageTypeNotHome="{x:Bind InstanceViewModel.IsPageTypeNotHome, Mode=OneWay}"
272-
NewFileInvokedCommand="{x:Bind CreateNewFileCommand}"
273-
NewFolderInvokedCommand="{x:Bind CreateNewFolderCommand}"
274-
NewPaneInvokedCommand="{x:Bind OpenNewPaneCommand}"
275-
NewTabInvokedCommand="{x:Bind AddNewTabToMultitaskingControlCommand}"
276-
NewWindowInvokedCommand="{x:Bind OpenNewWindowCommand}"
277-
OpenInTerminalInvokedCommand="{x:Bind OpenDirectoryInDefaultTerminalCommand}"
278-
PasteInvokedCommand="{x:Bind PasteItemsFromClipboardCommand}"
272+
NewFileInvokedCommand="{x:Bind CreateNewFileCommand, Mode=OneWay}"
273+
NewFolderInvokedCommand="{x:Bind CreateNewFolderCommand, Mode=OneWay}"
274+
NewPaneInvokedCommand="{x:Bind OpenNewPaneCommand, Mode=OneWay}"
275+
NewTabInvokedCommand="{x:Bind AddNewTabToMultitaskingControlCommand, Mode=OneWay}"
276+
NewWindowInvokedCommand="{x:Bind OpenNewWindowCommand, Mode=OneWay}"
277+
OpenInTerminalInvokedCommand="{x:Bind OpenDirectoryInDefaultTerminalCommand, Mode=OneWay}"
278+
PasteInvokedCommand="{x:Bind PasteItemsFromClipboardCommand, Mode=OneWay}"
279279
PreviewPaneEnabled="{x:Bind PreviewPaneEnabled, Mode=TwoWay}"
280280
ShowMultiPaneControls="{x:Bind converters1:MultiBooleanConverter.AndConvert(IsMultiPaneEnabled, IsPageMainPane), Mode=OneWay}" />
281281
</Custom:DropShadowPanel>

Files/Views/ModernShellPage.xaml.cs

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,27 @@ public bool IsPageMainPane
119119
}
120120
}
121121

122-
public ICommand SelectAllContentPageItemsCommand { get; private set; }
122+
public ICommand SelectAllContentPageItemsCommand => new RelayCommand(() => SlimContentPage?.SelectAllItems());
123123

124-
public ICommand InvertContentPageSelctionCommand { get; private set; }
124+
public ICommand InvertContentPageSelctionCommand => new RelayCommand(() => SlimContentPage?.InvertSelection());
125125

126-
public ICommand ClearContentPageSelectionCommand { get; private set; }
126+
public ICommand ClearContentPageSelectionCommand => new RelayCommand(() => SlimContentPage?.ClearSelection());
127127

128-
public ICommand PasteItemsFromClipboardCommand { get; private set; }
128+
public ICommand PasteItemsFromClipboardCommand => new RelayCommand(async () => await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this));
129129

130-
public ICommand CopyPathOfWorkingDirectoryCommand { get; private set; }
130+
public ICommand CopyPathOfWorkingDirectoryCommand => new RelayCommand(CopyWorkingLocation);
131131

132-
public ICommand OpenNewWindowCommand { get; private set; }
132+
public ICommand OpenNewWindowCommand => new RelayCommand(NavigationHelpers.LaunchNewWindow);
133133

134-
public ICommand OpenNewPaneCommand { get; private set; }
134+
public ICommand OpenNewPaneCommand => new RelayCommand(() => PaneHolder?.OpenPathInNewPane("NewTab".GetLocalized()));
135135

136-
public ICommand OpenDirectoryInDefaultTerminalCommand { get; private set; }
136+
public ICommand OpenDirectoryInDefaultTerminalCommand => new RelayCommand(() => NavigationHelpers.OpenDirectoryInTerminal(this.FilesystemViewModel.WorkingDirectory, this));
137137

138-
public ICommand AddNewTabToMultitaskingControlCommand { get; private set; }
138+
public ICommand AddNewTabToMultitaskingControlCommand => new RelayCommand(async () => await MainPageViewModel.AddNewTabByPathAsync(typeof(PaneHolderPage), "NewTab".GetLocalized()));
139139

140-
public ICommand CreateNewFileCommand { get; private set; }
140+
public ICommand CreateNewFileCommand => new RelayCommand(() => UIFilesystemHelpers.CreateFileFromDialogResultType(AddItemType.File, null, this));
141141

142-
public ICommand CreateNewFolderCommand { get; private set; }
142+
public ICommand CreateNewFolderCommand => new RelayCommand(() => UIFilesystemHelpers.CreateFileFromDialogResultType(AddItemType.Folder, null, this));
143143

144144
public static readonly DependencyProperty IsPageMainPaneProperty =
145145
DependencyProperty.Register("IsPageMainPane", typeof(bool), typeof(ModernShellPage), new PropertyMetadata(true));
@@ -212,25 +212,6 @@ public ModernShellPage()
212212
AppServiceConnectionHelper.ConnectionChanged += AppServiceConnectionHelper_ConnectionChanged;
213213
}
214214

215-
private void InitializeCommands()
216-
{
217-
if (this.SlimContentPage != null)
218-
{
219-
SelectAllContentPageItemsCommand = new RelayCommand(this.SlimContentPage.SelectAllItems);
220-
ClearContentPageSelectionCommand = new RelayCommand(this.SlimContentPage.ClearSelection);
221-
InvertContentPageSelctionCommand = new RelayCommand(this.SlimContentPage.InvertSelection);
222-
}
223-
PasteItemsFromClipboardCommand = new RelayCommand(async () => await UIFilesystemHelpers.PasteItemAsync(FilesystemViewModel.WorkingDirectory, this));
224-
CopyPathOfWorkingDirectoryCommand = new RelayCommand(CopyWorkingLocation);
225-
OpenNewWindowCommand = new RelayCommand(NavigationHelpers.LaunchNewWindow);
226-
OpenNewPaneCommand = new RelayCommand(() => PaneHolder?.OpenPathInNewPane("NewTab".GetLocalized()));
227-
OpenDirectoryInDefaultTerminalCommand = new RelayCommand(() => NavigationHelpers.OpenDirectoryInTerminal(this.FilesystemViewModel.WorkingDirectory, this));
228-
AddNewTabToMultitaskingControlCommand = new RelayCommand(async () => await MainPageViewModel.AddNewTabByPathAsync(typeof(PaneHolderPage), "NewTab".GetLocalized()));
229-
230-
CreateNewFileCommand = new RelayCommand(() => UIFilesystemHelpers.CreateFileFromDialogResultType(AddItemType.File, null, this));
231-
CreateNewFolderCommand = new RelayCommand(() => UIFilesystemHelpers.CreateFileFromDialogResultType(AddItemType.Folder, null, this));
232-
}
233-
234215
private void CopyWorkingLocation()
235216
{
236217
try
@@ -900,7 +881,6 @@ private void ViewModel_WorkingDirectoryModified(object sender, WorkingDirectoryM
900881
private async void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e)
901882
{
902883
ContentPage = await GetContentOrNullAsync();
903-
InitializeCommands();
904884
NavigationToolbar.ClearSearchBoxQueryText(true);
905885
if (ItemDisplayFrame.CurrentSourcePageType == typeof(GenericFileBrowser)
906886
|| ItemDisplayFrame.CurrentSourcePageType == typeof(GridViewBrowser))

0 commit comments

Comments
 (0)