diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PasteFormatTemplateSelector.cs b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PasteFormatTemplateSelector.cs new file mode 100644 index 0000000000..18f6b86f33 --- /dev/null +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PasteFormatTemplateSelector.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation +// The Microsoft Corporation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using AdvancedPaste.Models; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; + +namespace AdvancedPaste.Controls; + +public sealed partial class PasteFormatTemplateSelector : DataTemplateSelector +{ + public DataTemplate ItemTemplate { get; set; } + + public DataTemplate ItemTemplateDisabled { get; set; } + + protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) + { + bool isEnabled = item is PasteFormat pasteFormat && pasteFormat.IsEnabled; + + if (container is SelectorItem selector) + { + selector.IsEnabled = isEnabled; + } + + return isEnabled ? ItemTemplate : ItemTemplateDisabled; + } +} diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PromptBox.xaml b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PromptBox.xaml index 79a29ac872..69f675d4cb 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PromptBox.xaml +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Controls/PromptBox.xaml @@ -410,6 +410,7 @@ Spacing="2"> @@ -537,6 +539,7 @@ HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ui:VisualExtensions.NormalizedCenterPoint="0.5,0.5" + AutomationProperties.HelpText="{x:Bind ViewModel.CustomAIUnavailableErrorText, Mode=OneWay}" Command="{x:Bind GenerateCustomAICommand}" Content="{ui:FontIcon Glyph=, FontSize=16}" diff --git a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml index b4e99ebaed..a37e53f49e 100644 --- a/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml +++ b/src/modules/AdvancedPaste/AdvancedPaste/AdvancedPasteXAML/Pages/MainPage.xaml @@ -21,6 +21,77 @@ x:Name="customActionsToMinHeightConverter" ValueIfNonZero="40" ValueIfZero="0" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - @@ -196,10 +216,10 @@ x:Name="PasteOptionsListView" Grid.Row="0" VerticalAlignment="Bottom" - IsItemClickEnabled="False" - ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}" + IsItemClickEnabled="True" + ItemClick="PasteFormat_ItemClick" ItemContainerTransitions="{x:Null}" - ItemTemplate="{StaticResource PasteFormatTemplate}" + ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}" ItemsSource="{x:Bind ViewModel.StandardPasteFormats, Mode=OneWay}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollMode="Auto" @@ -217,10 +237,10 @@ x:Name="CustomActionsListView" Grid.Row="2" VerticalAlignment="Top" - IsItemClickEnabled="False" - ItemContainerStyle="{StaticResource PasteFormatListViewItemStyle}" + IsItemClickEnabled="True" + ItemClick="PasteFormat_ItemClick" ItemContainerTransitions="{x:Null}" - ItemTemplate="{StaticResource PasteFormatTemplate}" + ItemTemplateSelector="{StaticResource PasteFormatTemplateSelector}" ItemsSource="{x:Bind ViewModel.CustomActionPasteFormats, Mode=OneWay}" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollMode="Auto" @@ -232,7 +252,6 @@ Height="1" HorizontalAlignment="Stretch" Fill="{ThemeResource DividerStrokeColorDefaultBrush}" /> -