|
11 | 11 | d:DesignHeight="300"
|
12 | 12 | d:DesignWidth="600"
|
13 | 13 | d:DataContext="{d:DesignInstance domain:ListsAndGridsViewModel}">
|
14 |
| - |
| 14 | + |
15 | 15 | <UserControl.Resources>
|
16 | 16 | <ResourceDictionary>
|
17 | 17 | <ResourceDictionary.MergedDictionaries>
|
18 | 18 | <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.DataGrid.xaml" />
|
19 | 19 | </ResourceDictionary.MergedDictionaries>
|
20 | 20 | </ResourceDictionary>
|
21 | 21 | </UserControl.Resources>
|
22 |
| - |
| 22 | + |
23 | 23 | <StackPanel>
|
24 |
| - <TextBlock |
25 |
| - Style="{StaticResource MaterialDesignHeadline5TextBlock}" |
26 |
| - Text="Custom Columns"/> |
27 |
| - |
| 24 | + <StackPanel Orientation="Horizontal"> |
| 25 | + <TextBlock |
| 26 | + Style="{StaticResource MaterialDesignHeadline5TextBlock}" |
| 27 | + Text="Custom Columns"/> |
| 28 | + <TextBlock |
| 29 | + Style="{StaticResource MaterialDesignBody1TextBlock}" VerticalAlignment="Center" |
| 30 | + Margin="25,0,10,0" |
| 31 | + Text="SelectionUnit:"/> |
| 32 | + <ComboBox x:Name="selectionUnitComboBox" ItemsSource="{Binding SelectionUnits}" SelectedIndex="0" VerticalAlignment="Center" /> |
| 33 | + </StackPanel> |
| 34 | + |
28 | 35 | <smtx:XamlDisplay UniqueKey="grids_1">
|
29 | 36 | <DataGrid
|
30 | 37 | ItemsSource="{Binding Items1}"
|
31 | 38 | CanUserAddRows="False" AutoGenerateColumns="False"
|
32 |
| - HeadersVisibility="All"> |
| 39 | + HeadersVisibility="All" |
| 40 | + SelectionUnit="{Binding ElementName=selectionUnitComboBox, Path=SelectedValue}"> |
33 | 41 | <DataGrid.Resources>
|
34 | 42 | <domain:BindingProxy
|
35 | 43 | x:Key="DataContextProxy"
|
36 | 44 | Data="{Binding}" />
|
37 | 45 | </DataGrid.Resources>
|
38 |
| - |
| 46 | + |
39 | 47 | <DataGrid.Columns>
|
40 | 48 | <DataGridCheckBoxColumn
|
41 | 49 | Binding="{Binding IsSelected, UpdateSourceTrigger=PropertyChanged}"
|
|
47 | 55 | IsChecked="{Binding Data.IsAllItems1Selected, Source={StaticResource DataContextProxy}}"/>
|
48 | 56 | </Border>
|
49 | 57 | </DataGridCheckBoxColumn.Header>
|
50 |
| - |
| 58 | + |
51 | 59 | <DataGridCheckBoxColumn.HeaderStyle>
|
52 | 60 | <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
53 | 61 | <Setter Property="HorizontalContentAlignment" Value="Center" />
|
54 | 62 | </Style>
|
55 | 63 | </DataGridCheckBoxColumn.HeaderStyle>
|
56 | 64 | </DataGridCheckBoxColumn>
|
57 |
| - |
| 65 | + |
58 | 66 | <DataGridTextColumn
|
59 | 67 | Binding="{Binding Code}"
|
60 | 68 | Header="Code"
|
61 | 69 | ElementStyle="{StaticResource MaterialDesignDataGridTextColumnStyle}"
|
62 | 70 | EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}"/>
|
63 |
| - |
| 71 | + |
64 | 72 | <!-- if you want to use the pop up style (MaterialDesignDataGridTextColumnPopupEditingStyle), you must use MaterialDataGridTextColumn -->
|
65 | 73 | <materialDesign:DataGridTextColumn
|
66 | 74 | Header="Name"
|
|
74 | 82 | </Binding>
|
75 | 83 | </materialDesign:DataGridTextColumn.Binding>
|
76 | 84 | </materialDesign:DataGridTextColumn>
|
77 |
| - |
| 85 | + |
78 | 86 | <!-- set a max length to get an indicator in the editor -->
|
79 | 87 | <DataGridTextColumn
|
80 | 88 | Header="Description"
|
|
88 | 96 | </Binding>
|
89 | 97 | </DataGridTextColumn.Binding>
|
90 | 98 | </DataGridTextColumn>
|
91 |
| - |
| 99 | + |
92 | 100 | <materialDesign:DataGridTextColumn
|
93 | 101 | Binding="{Binding Numeric}"
|
94 | 102 | Header="Number with long header"
|
|
109 | 117 | </Setter>
|
110 | 118 | </Style>
|
111 | 119 | </DataGridTextColumn.HeaderStyle>
|
112 |
| - |
| 120 | + |
113 | 121 | <DataGridTextColumn.ElementStyle>
|
114 | 122 | <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource MaterialDesignDataGridTextColumnStyle}">
|
115 | 123 | <Setter Property="HorizontalAlignment" Value="Right" />
|
|
134 | 142 | <materialDesign:DataGridComboBoxColumn
|
135 | 143 | Header="ComboBox with long list"
|
136 | 144 | SelectedValueBinding="{Binding Files}"
|
137 |
| - ItemsSourceBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Files}"> |
| 145 | + ItemsSourceBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Files}" /> |
138 | 146 |
|
139 |
| - </materialDesign:DataGridComboBoxColumn> |
| 147 | + <DataGridTemplateColumn Header="Template Column"> |
| 148 | + <DataGridTemplateColumn.CellTemplate> |
| 149 | + <DataTemplate DataType="{x:Type domain:SelectableViewModel}"> |
| 150 | + <TextBlock Text="{Binding Name}" FontStyle="Italic" FontSize="14" /> |
| 151 | + </DataTemplate> |
| 152 | + </DataGridTemplateColumn.CellTemplate> |
| 153 | + <DataGridTemplateColumn.CellEditingTemplate> |
| 154 | + <DataTemplate DataType="{x:Type domain:SelectableViewModel}"> |
| 155 | + <TextBox Text="{Binding Name}" Foreground="{DynamicResource SecondaryHueMidBrush}" /> |
| 156 | + </DataTemplate> |
| 157 | + </DataGridTemplateColumn.CellEditingTemplate> |
| 158 | + </DataGridTemplateColumn> |
140 | 159 | </DataGrid.Columns>
|
141 | 160 | </DataGrid>
|
142 | 161 | </smtx:XamlDisplay>
|
|
145 | 164 | <materialDesign:PackIcon Kind="Information" Margin="0 0 5 0"/>
|
146 | 165 | <TextBlock>DataGridComboBoxColumns are virtualized by default in the library</TextBlock>
|
147 | 166 | </StackPanel>
|
148 |
| - |
| 167 | + |
149 | 168 | <TextBlock
|
150 | 169 | Style="{StaticResource MaterialDesignHeadline5TextBlock}"
|
151 | 170 | Text="Auto Generated Columns"
|
152 | 171 | Margin="0 24 0 0"/>
|
153 |
| - |
| 172 | + |
154 | 173 | <smtx:XamlDisplay UniqueKey="grids_2">
|
155 | 174 | <DataGrid
|
156 | 175 | ItemsSource="{Binding Items2}"
|
157 | 176 | CanUserAddRows="False"
|
158 | 177 | SelectionUnit="Cell"
|
159 | 178 | SelectionMode="Extended" />
|
160 | 179 | </smtx:XamlDisplay>
|
161 |
| - |
| 180 | + |
162 | 181 | <TextBlock
|
163 | 182 | Style="{StaticResource MaterialDesignHeadline6TextBlock}"
|
164 | 183 | Text="Custom Padding" Margin="0 24 0 0"/>
|
165 |
| - |
| 184 | + |
166 | 185 | <smtx:XamlDisplay UniqueKey="grids_3">
|
167 | 186 | <DataGrid
|
168 | 187 | ItemsSource="{Binding Items3}"
|
|
0 commit comments