TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sujeet Suman
386
4.1k
1.5m
How to bind a datagrid button using mvvm?
Aug 13 2020 5:20 AM
I have a datagrid & column contains a button. I would like to call a method in ViewModel on button click event.
<DataGrid x:Name="dgvEmp" HorizontalAlignment="Left" Height="120" Margin="10,10,0,0" VerticalAlignment="Top" Width="530"
CanUserAddRows="False" AutoGenerateColumns="False" ItemsSource="{Binding Employees}"
Style="{StaticResource styleDataGrid}">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding ID}" Width="110*"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="110*"/>
<DataGridTextColumn Header="Address" Binding="{Binding Address}" Width="110*"/>
<DataGridTemplateColumn Width="110*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Width="110"
Content="{Binding Path=ConnectionStatus}"
Command="{Binding UpdateDetailsCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
CommandParameter="{Binding Path=MACAddress}">
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Reply
Answers (
5
)
how to add a one row for column 1 - WPF
How can I retrieve the configuration values in a MainViewModel system