Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fixes #149 - Update Sample to use External ObservableCollection
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.)
  • Loading branch information
michael-hawker committed Sep 14, 2021
commit 5d1e8264cbab585974e909cdd4abaf9ebfe73d10
35 changes: 19 additions & 16 deletions SampleTest/Samples/PeoplePickerSample.xaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
<Page
x:Class="SampleTest.Samples.PeoplePickerSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SampleTest.Samples"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.Graph.Uwp.Controls"
xmlns:graph="using:Microsoft.Graph"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page x:Class="SampleTest.Samples.PeoplePickerSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.Graph.Uwp.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:graph="using:Microsoft.Graph"
xmlns:local="using:SampleTest.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<Page.Resources>
<graph:Person x:Key="GraphPerson" />
</Page.Resources>

<Grid>
<StackPanel>
<TextBlock Margin="0,0,0,16" TextWrapping="WrapWholeWords">
<TextBlock Margin="0,0,0,16"
TextWrapping="WrapWholeWords">
The `PeoplePicker` lets a logged in user easily search for familiar people they interact with or contacts. Great for emails or messages.
</TextBlock>
<controls:PeoplePicker x:Name="PeopleChooser" />
<TextBlock Margin="0,8,0,0" FontWeight="Bold">
<controls:PeoplePicker x:Name="PeopleChooser"
ItemsSource="{x:Bind MyPeople}" />
<TextBlock Margin="0,8,0,0"
FontWeight="Bold">
Picked People:
</TextBlock>
<ItemsControl Margin="8,0,0,0" ItemsSource="{x:Bind PeopleChooser.ItemsSource}">
<ItemsControl Margin="8,0,0,0"
ItemsSource="{x:Bind MyPeople}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="graph:Person">
<TextBlock Text="{x:Bind DisplayName}" />
Expand Down
4 changes: 4 additions & 0 deletions SampleTest/Samples/PeoplePickerSample.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.ObjectModel;
using Microsoft.Graph;
using Windows.UI.Xaml.Controls;

namespace SampleTest.Samples
{
public sealed partial class PeoplePickerSample : Page
{
ObservableCollection<Person> MyPeople { get; set; } = new();

public PeoplePickerSample()
{
InitializeComponent();
Expand Down