Skip to content

Commit 0785fff

Browse files
committed
Hide Command Items Dynamically
1 parent 1dc656b commit 0785fff

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Files/UserControls/NavigationToolbar/ModernNavigationToolbar.xaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@
683683
<Button
684684
x:Name="NewItemButton"
685685
Grid.Row="3"
686+
x:Load="{x:Bind local1:App.InteractionViewModel.IsPageTypeNotHome, Mode=OneWay}"
686687
Margin="0,0,4,0"
687688
HorizontalAlignment="Right"
688689
Background="Transparent"
@@ -769,16 +770,23 @@
769770
Text="New Window" />
770771
<MenuFlyoutItem
771772
x:Uid="NavigationToolbarCopyPath"
773+
x:Name="CopyPathButton"
774+
x:Load="{x:Bind local1:App.InteractionViewModel.IsPageTypeNotHome, Mode=OneWay}"
772775
Click="{x:Bind local1:App.CurrentInstance.InteractionOperations.GetPath_Click}"
773776
Text="Copy Path" />
774-
<MenuFlyoutSeparator />
777+
<MenuFlyoutSeparator x:Name="SeparatorBar" x:Load="{x:Bind local1:App.InteractionViewModel.IsPageTypeNotHome, Mode=OneWay}" />
775778
<MenuFlyoutItem
779+
x:Name="PasteButton"
776780
x:Uid="NavigationToolbarPaste"
781+
x:Load="{x:Bind local1:App.InteractionViewModel.IsPageTypeNotHome, Mode=OneWay}"
782+
IsEnabled="{x:Bind local1:App.PS.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
777783
Click="{x:Bind local1:App.CurrentInstance.InteractionOperations.PasteItem_ClickAsync}"
778784
Text="Paste" />
779785
<MenuFlyoutItem
786+
x:Name="OpenInTerminalButton"
780787
x:Uid="NavigationToolbarOpenInTerminal"
781788
Click="{x:Bind local1:App.CurrentInstance.InteractionOperations.OpenDirectoryInTerminal}"
789+
x:Load="{x:Bind local1:App.InteractionViewModel.IsPageTypeNotHome, Mode=OneWay}"
782790
Text="Open in Terminal..." />
783791
</MenuFlyout>
784792
</Button.Flyout>

Files/View Models/InteractionViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public bool IsSelectedItemImage
3434
set => Set(ref _IsSelectedItemImage, value);
3535
}
3636

37+
private bool _IsPageTypeNotHome = false;
38+
public bool IsPageTypeNotHome
39+
{
40+
get => _IsPageTypeNotHome;
41+
set => Set(ref _IsPageTypeNotHome, value);
42+
}
43+
3744
public void CheckForImage()
3845
{
3946
//check if the selected item is an image file

Files/Views/Pages/ModernShellPage.xaml.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,16 @@ private void ItemDisplayFrame_Navigated(object sender, NavigationEventArgs e)
151151
(ItemDisplayFrame.Content as GenericFileBrowser).AllView.Columns[0].GetCellContent(dataGridRow).Opacity = 1;
152152
}
153153
}
154+
App.InteractionViewModel.IsPageTypeNotHome = true;
155+
}
156+
else if (App.CurrentInstance.CurrentPageType == typeof(PhotoAlbum))
157+
{
158+
App.InteractionViewModel.IsPageTypeNotHome = true;
159+
}
160+
else if (App.CurrentInstance.CurrentPageType == typeof(YourHome))
161+
{
162+
App.InteractionViewModel.IsPageTypeNotHome = false;
154163
}
155-
156-
//RibbonArea.Focus(FocusState.Programmatic);
157164
}
158165

159166
public void UpdateProgressFlyout(InteractionOperationType operationType, int amountComplete, int amountTotal)

0 commit comments

Comments
 (0)