Skip to content

Commit

Permalink
feat: Add support for quicky opening searched item in SamplesApp
Browse files Browse the repository at this point in the history
  • Loading branch information
morning4coffe-dev committed Dec 1, 2023
1 parent f8468e8 commit 5b7cf3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,13 @@ private List<SampleChooserContent> UpdateSearch(string search, List<SampleChoose
return starts.Concat(contains).ToList();
}

public void TryOpenSample()
{
if (FilteredSamples.Count is 1)
{
SelectedSearchSample = FilteredSamples[0];
}
}

/// <summary>
/// This method is used to get the list of samplechoosercontent that is present in the settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@

<TextBox Text="{Binding SearchTerm, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Style="{StaticResource SearchTextBoxStyle}"
KeyDown="OnSearchEnterKey_KeyDown"
PlaceholderText="Search"
Margin="8" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Windows.Foundation;
using Windows.UI.Xaml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Windows.UI.Xaml.Input;

#if NETFX_CORE
using Windows.Foundation.Collections;
using Windows.UI.Xaml.Controls;
Expand Down Expand Up @@ -53,5 +55,13 @@ protected override Size ArrangeOverride(Size availableSize)
}
return base.ArrangeOverride(availableSize);
}

private void OnSearchEnterKey_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key == Windows.System.VirtualKey.Enter)
{
(DataContext as SampleChooserViewModel).TryOpenSample();
}
}
}
}

0 comments on commit 5b7cf3b

Please sign in to comment.