/
MainWindow.xaml
39 lines (35 loc) · 1.8 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<Window x:Class="AddRemoveRows.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:local="clr-namespace:AddRemoveRows"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<dxg:GridControl AutoGenerateColumns="AddNew"
ItemsSource="{Binding Products}">
<dxg:GridControl.View>
<dxg:TableView AutoWidth="True">
<dxg:TableView.RowCellMenuCustomizations>
<dxb:BarButtonItem Content="Delete" Command="{x:Static dxg:GridCommands.DeleteFocusedRow}"/>
</dxg:TableView.RowCellMenuCustomizations>
<dxmvvm:Interaction.Behaviors >
<local:AddRemoveRowBehavior x:Name="behavior"/>
</dxmvvm:Interaction.Behaviors>
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
<StackPanel Grid.Column="1">
<Button Command="{Binding AddCommand, ElementName=behavior}" Width="160" Height="50" Margin="10">Add a New Row</Button>
<Button Command="{Binding DeleteCommand, ElementName=behavior}" Width="160" Height="50" Margin="10">Delete the Focused Row</Button>
</StackPanel>
</Grid>
</Window>