-
Notifications
You must be signed in to change notification settings - Fork 2
/
MainWindow.xaml
41 lines (41 loc) · 2.52 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
40
41
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ColumnsSample"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxci="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
x:Class="ColumnsSample.MainWindow" mc:Ignorable="d"
Title="MainWindow" Height="400" Width="700">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="DefaultColumnTemplate">
<dxg:GridColumn FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"/>
</DataTemplate>
<DataTemplate x:Key="LookupColumnTemplate">
<dxg:GridColumn FieldName="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Source}"/>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</DataTemplate>
<DataTemplate x:Key="BindingColumnTemplate">
<dxg:GridColumn local:BindingHelper.Path="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).FieldName, RelativeSource={RelativeSource Self}}"
Header="{Binding Path=(dxci:DependencyObjectExtensions.DataContext).Header, RelativeSource={RelativeSource Self}}"/>
</DataTemplate>
<local:ColumnTemplateSelector x:Key="ColumnTemplateSelector"
DefaultColumnTemplate ="{StaticResource DefaultColumnTemplate}"
LookupColumnTemplate ="{StaticResource LookupColumnTemplate}"
BindingColumnTemplate ="{StaticResource BindingColumnTemplate}"/>
</Window.Resources>
<dxg:GridControl ItemsSource="{Binding Source}" ColumnsSource="{Binding Columns}"
ColumnGeneratorTemplateSelector="{StaticResource ColumnTemplateSelector}">
<dxg:GridControl.View>
<dxg:TableView />
</dxg:GridControl.View>
</dxg:GridControl>
</Window>