public async Task Init()
        {
            await App.Dispatcher.EnqueueAsync(() =>
            {
                _acv = new AdvancedCollectionView(_samples, false);

                _acv.SortDescriptions.Add(new SortDescription(nameof(SampleDataType.Text), SortDirection.Ascending));

                var xamlTokenizingTextBox = @"<controls:TokenizingTextBox xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
                                                 xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                                                 xmlns:controls='using:Microsoft.Toolkit.Uwp.UI.Controls'
                          PlaceholderText='Add Actions'
                          MaxHeight='104'
                          HorizontalAlignment='Center'
                          VerticalAlignment='Center'
                          TextMemberPath='Text'
                          TokenDelimiter = ','>
                        <controls:TokenizingTextBox.SuggestedItemTemplate>
                          <DataTemplate>
                            <StackPanel Orientation='Horizontal'>
                              <SymbolIcon Symbol='{Binding Icon}'/>
                              <TextBlock Text='{Binding Text}' Padding='4,0,0,0'/>
                            </StackPanel>
                          </DataTemplate>
                        </controls:TokenizingTextBox.SuggestedItemTemplate>
                        <controls:TokenizingTextBox.TokenItemTemplate>
                          <DataTemplate>
                            <StackPanel Orientation='Horizontal'>
                              <SymbolIcon Symbol='{Binding Icon}'/>
                              <TextBlock Text='{Binding Text}' Padding='4,0,0,0'/>
                            </StackPanel>
                          </DataTemplate>
                        </controls:TokenizingTextBox.TokenItemTemplate>
                      </controls:TokenizingTextBox>";

                _tokenizingTextBox = XamlReader.Load(xamlTokenizingTextBox) as TokenizingTextBox;
                _tokenizingTextBox.SuggestedItemsSource = _acv;

                TestsPage.Instance.SetMainTestContent(_tokenizingTextBox);

                _tokenizingTextBox.AddTokenItem(_samples[0], true);
                _tokenizingTextBox.AddTokenItem(_samples[1], true);
                _tokenizingTextBox.AddTokenItem(_samples[2], true);
            });
        }
Beispiel #2
0
        private void EmailList_ItemClick(object sender, ItemClickEventArgs e)
        {
            // TODO: not sure how this is getting to be null, need to make simple repro and file platform issue?
            if (e.ClickedItem != null && e.ClickedItem is SampleEmailDataType email)
            {
                _ttbEmail.Text = string.Empty; // Clear current text

                _ttbEmail.AddTokenItem(email); // Insert new token with picked item to current text location

                _acvEmail.RefreshFilter();

                _ttbEmail.Focus(FocusState.Programmatic); // Give focus back to type another filter
            }
        }