Skip to content

Commit

Permalink
Apply fix to sample to show proper way to use TokenizingTextBox Bindi…
Browse files Browse the repository at this point in the history
…ng to ItemsSource

Avoids bug #4248
  • Loading branch information
michael-hawker committed Sep 14, 2021
1 parent 03c3f3c commit d528479
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public sealed partial class TokenizingTextBoxPage : Page, IXamlRenderListener
private AdvancedCollectionView _acv;
private AdvancedCollectionView _acvEmail;

private ObservableCollection<SampleEmailDataType> _selectedEmails;
public ObservableCollection<SampleDataType> SelectedTokens { get; set; }

public ObservableCollection<SampleEmailDataType> SelectedEmails { get; set; }

public TokenizingTextBoxPage()
{
Expand All @@ -112,7 +114,10 @@ public TokenizingTextBoxPage()

public void OnXamlRendered(FrameworkElement control)
{
_selectedEmails = new ObservableCollection<SampleEmailDataType>();
SelectedTokens = new();
SelectedEmails = new();

control.DataContext = this;

if (_ttb != null)
{
Expand Down Expand Up @@ -150,7 +155,6 @@ public void OnXamlRendered(FrameworkElement control)
{
_ttbEmail = ttbEmail;

_ttbEmail.ItemsSource = _selectedEmails;
_ttbEmail.ItemClick += EmailTokenItemClick;
_ttbEmail.TokenItemAdding += EmailTokenItemAdding;
_ttbEmail.TokenItemAdded += EmailTokenItemAdded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
</TextBlock>
<controls:TokenizingTextBox
x:Name="TokenBox"
ItemsSource="{Binding SelectedTokens}"
PlaceholderText="Add Actions"
QueryIcon="{ui:SymbolIconSource Symbol=Setting}"
MaxHeight="104"
Expand Down Expand Up @@ -65,14 +66,15 @@
<Run>Current Edit: </Run>
<Run Text="{Binding Text, ElementName=TokenBox}"/>
</TextBlock>
<ItemsControl ItemsSource="{Binding ItemsSource, ElementName=TokenBox}"/>
<ItemsControl ItemsSource="{Binding SelectedTokens}"/>
</StackPanel>

<StackPanel Grid.Row="1">
<TextBlock FontSize="32" Text="Select Email Addresses"
Margin="0,0,0,4"/>
<controls:TokenizingTextBox
x:Name="TokenBoxEmail"
ItemsSource="{Binding SelectedEmails}"
PlaceholderText="Select Names"
MaxHeight="104"
HorizontalAlignment="Stretch"
Expand Down

0 comments on commit d528479

Please sign in to comment.