I am trying to pass UserName by CommandParameter.
<GridViewColumn Width="Auto" Header="UserName" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Click="Button_Click" Content="..." CommandParameter="{Binding Path=UserName}"></Button> </DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
But here I am not sure what do I have to use to catch it…
private void Button_Click(object sender, RoutedEventArgs e)
{
// How to get UserName here?
}
Any clue?
Thank you!
Best you can do with such approach is this:
Though it will do the job but it is not how
CommandParameteris supposed to be used.CommandParameteris supposed to be passed as parameter to button’s command. So if you will useCommandinstead of handlingButton.Clickyour command will receive your data in itsExecuteandCanExecutehandlers. See samples for commands&buttons in google. Here is first link from google for example: How to use Commands in WPF