In my Xaml view I have a button that displays a list of users in a list:
<Button Grid.Row="0" Content="Button" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Column="1" Margin="0,-5,-1,0">
<Button.Flyout>
<Flyout>
<GridView
SelectionMode="Multiple"
Background="Azure"
x:Name="ContactList"
ItemsSource="{Binding Path=ListOfUsers}">
<GridView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock>
<Run FontWeight="Bold" Text="{Binding FirstName}" />
<Run Text="{Binding LastName}" />
</TextBlock>
</StackPanel>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
</Flyout>
</Button.Flyout>
</Button>
As you can see I have selectionMode
set to multiple which allows me to select several items from the list.
My question is, how can i bind my selection to a property on my ViewModel:
private ObservableCollection<User> _selectedUsers;
public ObservableCollection<User> SelectedUsers
{
get { return _selectedUsers; }
set
{
_selectedUsers = value;
RaisePropertyChanged("SelectedUsers");
}
}
Ideally, I would like to place a button i the flyout that I can click after havinug made my selection. Any help with this appreciated. Thank you.