Skip to content

Commit 1ca6164

Browse files
Fixes #149 - Update Sample to use External ObservableCollection (#160)
We re-write the sample to use an external collection as a developer would in their app. This then properly lets the ItemsControl display just the tokenized items. (Though there's still an issue with how TokenizingTextBox behaves we should resolve.)
1 parent a179cbc commit 1ca6164

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

SampleTest/Samples/PeoplePickerSample.xaml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
1-
<Page
2-
x:Class="SampleTest.Samples.PeoplePickerSample"
3-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:local="using:SampleTest.Samples"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
xmlns:controls="using:CommunityToolkit.Graph.Uwp.Controls"
9-
xmlns:graph="using:Microsoft.Graph"
10-
mc:Ignorable="d"
11-
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
1+
<Page x:Class="SampleTest.Samples.PeoplePickerSample"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:controls="using:CommunityToolkit.Graph.Uwp.Controls"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:graph="using:Microsoft.Graph"
7+
xmlns:local="using:SampleTest.Samples"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
10+
mc:Ignorable="d">
1211

1312
<Page.Resources>
1413
<graph:Person x:Key="GraphPerson" />
1514
</Page.Resources>
16-
15+
1716
<Grid>
1817
<StackPanel>
19-
<TextBlock Margin="0,0,0,16" TextWrapping="WrapWholeWords">
18+
<TextBlock Margin="0,0,0,16"
19+
TextWrapping="WrapWholeWords">
2020
The `PeoplePicker` lets a logged in user easily search for familiar people they interact with or contacts. Great for emails or messages.
2121
</TextBlock>
22-
<controls:PeoplePicker x:Name="PeopleChooser" />
23-
<TextBlock Margin="0,8,0,0" FontWeight="Bold">
22+
<controls:PeoplePicker x:Name="PeopleChooser"
23+
ItemsSource="{x:Bind MyPeople}" />
24+
<TextBlock Margin="0,8,0,0"
25+
FontWeight="Bold">
2426
Picked People:
2527
</TextBlock>
26-
<ItemsControl Margin="8,0,0,0" ItemsSource="{x:Bind PeopleChooser.ItemsSource}">
28+
<ItemsControl Margin="8,0,0,0"
29+
ItemsSource="{x:Bind MyPeople}">
2730
<ItemsControl.ItemTemplate>
2831
<DataTemplate x:DataType="graph:Person">
2932
<TextBlock Text="{x:Bind DisplayName}" />

SampleTest/Samples/PeoplePickerSample.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System.Collections.ObjectModel;
6+
using Microsoft.Graph;
57
using Windows.UI.Xaml.Controls;
68

79
namespace SampleTest.Samples
810
{
911
public sealed partial class PeoplePickerSample : Page
1012
{
13+
ObservableCollection<Person> MyPeople { get; set; } = new();
14+
1115
public PeoplePickerSample()
1216
{
1317
InitializeComponent();

0 commit comments

Comments
 (0)