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
Ayappan A
1.6k
98
12.7k
MVVM Binding for Datagrid column inside itemscontrol
Nov 29 2019 3:24 AM
How to Bind Button command event for DataGrid inside ItemsControl.
I want
1.CellCommand evet for CellEditEnding
2.AddNew command for button
<ItemsControl ItemsSource="{Binding ObjCollection}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Height="200">
<Label Content="{Binding Name}"/>
<DataGrid Name="dGrid" VerticalScrollBarVisibility="Auto" MaxHeight="150" ItemsSource="{Binding Dt}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="CellEditEnding">
<i:InvokeCommandAction Command="{Binding CellCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<DataGrid.Columns>
<DataGridTemplateColumn DisplayIndex="15">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="Add New" Command="{Binding Path=DataContext.AddNew, RelativeSource= {RelativeSource FindAncestor,
AncestorType={x:Type DataGrid}
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Reply
Answers (
5
)
How to select data from DataGrid in WPF MVVM with database
Material Design Backend Code