Skip to content

Commit 5f5753b

Browse files
committed
Aot safe mode change in XAML
1 parent e3ff6c0 commit 5f5753b

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/Files.App.Controls/Omnibar/Omnibar.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ protected void ChangeMode(OmnibarMode? oldMode, OmnibarMode newMode)
153153

154154
VisualStateManager.GoToState(newMode, "Focused", true);
155155
newMode.IsTabStop = false;
156+
157+
_textBox.PlaceholderText = newMode.PlaceholderText ?? string.Empty;
158+
_textBoxSuggestionsListView.ItemTemplate = newMode.SuggestionItemTemplate;
159+
_textBoxSuggestionsListView.ItemsSource = newMode.SuggestionItemsSource;
160+
156161
if (newMode.IsAutoFocusEnabled)
157162
{
158163
_textBox.Focus(FocusState.Pointer);

src/Files.App.Controls/Omnibar/Omnibar.xaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
FontStretch="{TemplateBinding FontStretch}"
6868
FontWeight="{TemplateBinding FontWeight}"
6969
Foreground="{TemplateBinding Foreground}"
70-
PlaceholderText="{Binding CurrentSelectedMode.PlaceholderText, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
7170
ScrollViewer.BringIntoViewOnFocusChange="False"
7271
Style="{StaticResource DefaultOmnibarTextBoxStyle}"
7372
UseSystemFocusVisuals="{TemplateBinding UseSystemFocusVisuals}" />
@@ -96,11 +95,7 @@
9695
MaxHeight="{ThemeResource AutoSuggestListMaxHeight}"
9796
Margin="{ThemeResource AutoSuggestListPadding}"
9897
IsItemClickEnabled="True"
99-
ItemTemplate="{Binding CurrentSelectedMode.SuggestionItemTemplate, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
100-
ItemsSource="{Binding CurrentSelectedMode.SuggestionItemsSource, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
101-
SelectionMode="Single">
102-
<ListView.ItemContainerTransitions />
103-
</ListView>
98+
SelectionMode="Single" />
10499
</Border>
105100
</Popup>
106101

src/Files.App/UserControls/NavigationToolbar.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,13 @@ private async void Omnibar_QuerySubmitted(Omnibar sender, OmnibarQuerySubmittedE
262262
}
263263
else if (Omnibar.CurrentSelectedMode == OmnibarCommandPaletteMode)
264264
{
265-
if (args.Item is not NavigationBarSuggestionItem item || item.Text is not { } commandText)
265+
string commandText = args.Item is NavigationBarSuggestionItem { Text: string itemText }
266+
? itemText
267+
: args.Text is string text
268+
? text
269+
: string.Empty;
270+
271+
if (string.IsNullOrEmpty(commandText))
266272
return;
267273

268274
var command = Commands[commandText];
@@ -276,6 +282,7 @@ await DialogDisplayHelper.ShowDialogAsync(Strings.CommandNotExecutable.GetLocali
276282
await command.ExecuteAsync();
277283

278284
ViewModel.OmnibarCurrentSelectedMode = OmnibarPathMode;
285+
ViewModel.OmnibarCommandPaletteModeText = string.Empty;
279286
}
280287
else if (Omnibar.CurrentSelectedMode == OmnibarSearchMode)
281288
{

0 commit comments

Comments
 (0)