0

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.

bugsy
  • 111
  • 2
  • 13
  • Have you even searched for it? Maybe this can help you http://stackoverflow.com/questions/5741161/how-to-bind-multiple-selection-of-listview-to-viewmodel – Sagiv b.g Feb 09 '15 at 17:09
  • Thanks for the link. Yes, i´ve been searching a lot and im hoping to find an easier solution. It seems like a common task that should have a more standarized solution i would think. – bugsy Feb 09 '15 at 19:54

0 Answers0