Jak przekazać wybrane pole listy jako parametr polecenia w przycisku?
Oto moja sytuacja:
<ListBox ItemsSource="{Binding Path=AvailableUsers}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Id}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Command="{Binding Path=Load}" CommandParameter={???? What goes here ????}/>
Chcę przekazać Id, który jest aktualnie wybrany w ListBox. Mam scenariusz za kulisami, który zasadniczo wygląda tak:
public class ViewModel : DependencyObject
{
ICommand Load { get; set; }
// dependency property but I didn't bother to write it out like one
List<User> AvailableUsers { get; set}
}
Jak mogę wysłać aktualnie wybrany element za pomocą xaml?