Вот моя ситуация:
<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 ????}/>
Я хочу передать идентификатор, который в настоящее время выбран в ListBox. У меня есть viewmodel за кулисами, который выглядит примерно так:
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}
}
Как я могу отправить текущий выбранный элемент с помощью xaml?