Windows 10 Version 1607 - September 2017 Update

This commit is contained in:
Raymond Chen 2017-09-13 17:00:02 -07:00
Родитель 38092394f0 b421089dac
Коммит 50c35a528a
5 изменённых файлов: 27 добавлений и 14 удалений

Просмотреть файл

@ -42,6 +42,11 @@ void Scenario1::asb_TextChanged(AutoSuggestBox^ sender, AutoSuggestBoxTextChange
sender->ItemsSource = ref new Vector<Contact^>(matchingContacts);
}
if (args->Reason != AutoSuggestionBoxTextChangeReason::SuggestionChosen)
{
rootPage->NotifyUser("", NotifyType::StatusMessage);
}
}
/// <summary>
@ -55,6 +60,8 @@ void Scenario1::asb_TextChanged(AutoSuggestBox^ sender, AutoSuggestBoxTextChange
/// and also ChosenSuggestion, which is only non-null when a user selects an item in the list.</param>
void Scenario1::asb_QuerySubmitted(AutoSuggestBox^ sender, AutoSuggestBoxQuerySubmittedEventArgs^ args)
{
rootPage->NotifyUser("", NotifyType::StatusMessage);
if (args->ChosenSuggestion != nullptr)
{
// User selected an item, take an action on it here
@ -71,17 +78,16 @@ void Scenario1::asb_QuerySubmitted(AutoSuggestBox^ sender, AutoSuggestBoxQuerySu
}
/// <summary>
/// This event gets fired as the user keys through the list, or taps on a suggestion.
/// This allows you to change the text in the TextBox to reflect the item in the list.
/// Alternatively you can use TextMemberPath.
/// This event is raised as the user keys through the list, or taps on a suggestion.
/// The AutoSuggestBox.TextMemberPath property controls what text appears in the TextBox.
/// You could use this event to trigger a prefetch of the suggestion.
/// </summary>
/// <param name="sender">The AutoSuggestBox that fired the event.</param>
/// <param name="args">The args contain SelectedItem, which contains the data item of the item that is currently highlighted.</param>
void Scenario1::asb_SuggestionChosen(AutoSuggestBox^ sender, AutoSuggestBoxSuggestionChosenEventArgs^ args)
{
auto contact = safe_cast<Contact^>(args->SelectedItem);
sender->Text = contact->DisplayName;
rootPage->NotifyUser("Suggestion chosen: " + contact->DisplayName, NotifyType::StatusMessage);
}
/// <summary>

Просмотреть файл

@ -23,9 +23,9 @@ namespace SDKTemplate
public:
Scenario1();
protected:
private:
MainPage^ rootPage = MainPage::Current;
void asb_TextChanged(Windows::UI::Xaml::Controls::AutoSuggestBox^ sender, Windows::UI::Xaml::Controls::AutoSuggestBoxTextChangedEventArgs^ args);
void asb_QuerySubmitted(Windows::UI::Xaml::Controls::AutoSuggestBox^ sender, Windows::UI::Xaml::Controls::AutoSuggestBoxQuerySubmittedEventArgs^ args);
void asb_SuggestionChosen(Windows::UI::Xaml::Controls::AutoSuggestBox^ sender, Windows::UI::Xaml::Controls::AutoSuggestBoxSuggestionChosenEventArgs^ args);

Просмотреть файл

@ -53,6 +53,11 @@ namespace SDKTemplate
sender.ItemsSource = matchingContacts.ToList();
}
if (args.Reason != AutoSuggestionBoxTextChangeReason.SuggestionChosen)
{
rootPage.NotifyUser("", NotifyType.StatusMessage);
}
}
/// <summary>
@ -66,6 +71,8 @@ namespace SDKTemplate
/// and also ChosenSuggestion, which is only non-null when a user selects an item in the list.</param>
private void asb_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
rootPage.NotifyUser("", NotifyType.StatusMessage);
if (args.ChosenSuggestion != null)
{
// User selected an item, take an action on it here
@ -82,17 +89,16 @@ namespace SDKTemplate
}
/// <summary>
/// This event gets fired as the user keys through the list, or taps on a suggestion.
/// This allows you to change the text in the TextBox to reflect the item in the list.
/// Alternatively you can use TextMemberPath.
/// This event is raised as the user keys through the list, or taps on a suggestion.
/// The AutoSuggestBox.TextMemberPath property controls what text appears in the TextBox.
/// You could use this event to trigger a prefetch of the suggestion.
/// </summary>
/// <param name="sender">The AutoSuggestBox that fired the event.</param>
/// <param name="args">The args contain SelectedItem, which contains the data item of the item that is currently highlighted.</param>
private void asb_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
{
var contact = (Contact)args.SelectedItem;
sender.Text = contact.DisplayName;
rootPage.NotifyUser("Suggestion chosen: " + contact.DisplayName, NotifyType.StatusMessage);
}
/// <summary>

Просмотреть файл

@ -526,7 +526,7 @@ Ray
Layla
Springe
Chadds Ford Winery
Joesph
Joseph
Degonia
A R Packaging
Annabelle

Просмотреть файл

@ -34,7 +34,7 @@
<Paragraph>In Windows 10, SearchBox is no longer being supported, in favor of AutoSuggestBox. As such, this example is meant to showcase using AutoSuggestBox to get a SearchBox-style experience.</Paragraph>
<Paragraph>The key events in AutoSuggestBox that you will need to utilize are TextChanged, SuggestionChosen, and QuerySubmitted. Using these events in conjunction with QueryIcon will allow you to have the same experience as SearchBox using AutoSuggestBox.</Paragraph>
<Paragraph TextIndent="15">• TextChanged - This event is where you will filter your result set based on the text that the user has input.</Paragraph>
<Paragraph TextIndent="15">• SuggestionChosen - This event will allow you to fill in the TextBox with the text of the highlighted item. This is fired as a user keys down the list and when an item is tapped.</Paragraph>
<Paragraph TextIndent="15">• SuggestionChosen - This event is fired as a user keys down the list and when an item is tapped.</Paragraph>
<Paragraph TextIndent="15">• QuerySubmitted - This event is where you should take action. There are 2 key properties in the args for this event:</Paragraph>
<Paragraph TextIndent="30">◦ QueryText - This is the text in the TextBox. Use this if ChosenSuggestion is null, as it means that the user either pressed Enter in the TextBox, or clicked on the QueryIcon button.</Paragraph>
<Paragraph TextIndent="30">◦ ChosenSuggestion - If a user tapped on an item in the list, or pressed Enter while it was highlighted, this will contain the data item corresponding to the item in the list that was selected.</Paragraph>
@ -50,6 +50,7 @@
x:Name="asb"
PlaceholderText="Type a name (e.g. John)"
DisplayMemberPath="DisplayName"
TextMemberPath="DisplayName"
TextChanged="asb_TextChanged"
QueryIcon="Find"
QuerySubmitted="asb_QuerySubmitted"