Answer the question
In order to leave comments, you need to log in
How to open a form on click on a row in DataGrid?
I don't really understand how to track a click on the DataGrid. here is the xaml markup:
<DataGrid AutoGenerateColumns="False" x:Name="dg_recipes" Margin="10,249,10,10">
<DataGrid.Columns>
<DataGridTextColumn Header="Название" Binding="{Binding Path='name'}" Width="320"/>
<DataGridTextColumn Header="Время приготовления" Width="280"/>
</DataGrid.Columns>
</DataGrid>
Answer the question
In order to leave comments, you need to log in
<DataGrid Name="MyDataGrid" ItemsSource="{Binding Table}">
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Click="Button_Click">Open Form</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
private void Button_Click(object sender, RoutedEventArgs e)
{
TosterForm form = new TosterForm(((DataRowView)MyDataGrid.SelectedItem).Row.ItemArray[3].ToString());
form.ShowDialog();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question