|
21 | 21 | </ControlTemplate> |
22 | 22 |
|
23 | 23 | <ControlTemplate x:Key="FilterWithPopup"> |
24 | | - <src:FilterWithPopupControl Filter="{Binding Path=Filter, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}}"/> |
| 24 | + <src:FilterWithPopupControl Filter="{Binding Path=Filter, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}}" /> |
25 | 25 | </ControlTemplate> |
26 | 26 |
|
27 | 27 | <ControlTemplate x:Key="MultipleChoiceFilter"> |
28 | | - <src:MultipleChoiceFilter Filter="{Binding Path=Filter, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}}"/> |
| 28 | + <src:MultipleChoiceFilter Filter="{Binding Path=Filter, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}}" /> |
29 | 29 | </ControlTemplate> |
30 | 30 |
|
31 | 31 | <ControlTemplate x:Key="ComboboxFilter"> |
32 | 32 | <Grid d:DataContext="{d:DesignInstance dgx:DataGridFilterColumnControl}"> |
33 | 33 | <Grid> |
34 | | - <Control Style="{DynamicResource {x:Static dgx:DataGridFilter.IconStyleKey}}"/> |
| 34 | + <Control Style="{DynamicResource {x:Static dgx:DataGridFilter.IconStyleKey}}" /> |
35 | 35 | <ComboBox x:Name="ComboBox" Text="{Binding Path=Filter, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding SourceValues}" IsEditable="True" /> |
36 | 36 | </Grid> |
37 | 37 | </Grid> |
|
56 | 56 | <Setter Property="VerticalGridLinesBrush" Value="LightGray" /> |
57 | 57 | </Style> |
58 | 58 |
|
59 | | - <XmlDataProvider x:Key="ComboBoxSource" Source="SampleList.xml" XPath="Items/Item"/> |
| 59 | + <XmlDataProvider x:Key="ComboBoxSource" Source="SampleList.xml" XPath="Items/Item" /> |
60 | 60 |
|
61 | 61 | <CollectionViewSource x:Key="SortedItems" Source="{Binding Items}"> |
62 | 62 | <CollectionViewSource.SortDescriptions> |
63 | | - <componentModel:SortDescription PropertyName="Column1"/> |
| 63 | + <componentModel:SortDescription PropertyName="Column1" /> |
64 | 64 | </CollectionViewSource.SortDescriptions> |
65 | 65 | </CollectionViewSource> |
66 | 66 |
|
67 | 67 | <Style x:Key="DataGridComboBoxStyle" TargetType="ComboBox"> |
68 | | - <Setter Property="BorderThickness" Value="0"/> |
69 | | - <Setter Property="Padding" Value="3,2,0,0"/> |
70 | | - <Setter Property="Foreground" Value="Green"/> |
| 68 | + <Setter Property="BorderThickness" Value="0" /> |
| 69 | + <Setter Property="Padding" Value="3,2,0,0" /> |
| 70 | + <Setter Property="Foreground" Value="Green" /> |
71 | 71 | </Style> |
72 | 72 | <Style x:Key="DataGridTextBlockStyle" TargetType="TextBlock"> |
73 | | - <Setter Property="Foreground" Value="Blue"/> |
| 73 | + <Setter Property="Foreground" Value="Blue" /> |
74 | 74 | </Style> |
75 | 75 |
|
76 | 76 | </Window.Resources> |
|
90 | 90 | <Decorator Height="10" /> |
91 | 91 | <StackPanel Orientation="Horizontal"> |
92 | 92 | <CheckBox x:Name="IsFilterEnabled" DockPanel.Dock="Top" IsChecked="True" Content="Enable filters" VerticalAlignment="Center" /> |
93 | | - <Decorator Width="20"/> |
| 93 | + <Decorator Width="20" /> |
94 | 94 | <Button Click="ClearAllFilters_Click">Clear all filters</Button> |
95 | 95 | </StackPanel> |
96 | 96 | </StackPanel> |
|
99 | 99 | dgx:DataGridFilter.IsAutoFilterEnabled="{Binding Path=IsChecked, ElementName=IsFilterEnabled}"> |
100 | 100 | <DataGrid.ItemsPanel> |
101 | 101 | <ItemsPanelTemplate> |
102 | | - <VirtualizingStackPanel KeyboardNavigation.DirectionalNavigation="Contained"/> |
| 102 | + <VirtualizingStackPanel KeyboardNavigation.DirectionalNavigation="Contained" /> |
103 | 103 | </ItemsPanelTemplate> |
104 | 104 | </DataGrid.ItemsPanel> |
105 | | - </DataGrid></DockPanel> |
| 105 | + </DataGrid> |
| 106 | + </DockPanel> |
106 | 107 | </TabItem> |
107 | 108 |
|
108 | 109 | <TabItem Header="Extended 1"> |
109 | 110 | <DockPanel> |
110 | 111 | <TextBlock DockPanel.Dock="Top" Margin="10" TextWrapping="WrapWithOverflow"> |
111 | | - <Run>This tab shows how to customize the filters when using auto generated columns. See the DataGrid_AutoGeneratingColumn event handler for details.</Run><LineBreak/> |
112 | | - <Run>- Overrides the content filter factory to use the regex matching instead of the default simple "string contains" matching.</Run><LineBreak/> |
| 112 | + <Run>This tab shows how to customize the filters when using auto generated columns. See the DataGrid_AutoGeneratingColumn event handler for details.</Run><LineBreak /> |
| 113 | + <Run>- Overrides the content filter factory to use the regex matching instead of the default simple "string contains" matching.</Run><LineBreak /> |
113 | 114 | <Run>- Uses the sample IntergerFilter for the Index column.</Run> |
114 | 115 | </TextBlock> |
115 | 116 | <DataGrid ItemsSource="{Binding Items}" |
|
119 | 120 | <DataGrid.Resources> |
120 | 121 | <!-- Override the filter icon used in the default templates with a fat orange symbol; active for this grid only --> |
121 | 122 | <ControlTemplate x:Key="{x:Static dgx:DataGridFilter.IconTemplateKey}"> |
122 | | - <Path Data="M0,0 L10,0 7,5 7,9 3,9 3,5 Z" Fill="Orange" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2,0"/> |
| 123 | + <Path Data="M0,0 L10,0 7,5 7,9 3,9 3,5 Z" Fill="Orange" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="2,0" /> |
123 | 124 | </ControlTemplate> |
124 | 125 | </DataGrid.Resources> |
125 | 126 |
|
126 | 127 | <i:Interaction.Behaviors> |
127 | | - <dgx:ExtendedStarSizeBehavior/> |
128 | | - <dgx:BeginEditOnCtrlEnterBehavior/> |
129 | | - <dgx:DisableTargetWhileEditingBehavior Target="{Binding ElementName=ReloadButton}"/> |
| 128 | + <dgx:ExtendedStarSizeBehavior /> |
| 129 | + <dgx:BeginEditOnCtrlEnterBehavior /> |
| 130 | + <dgx:DisableTargetWhileEditingBehavior Target="{Binding ElementName=ReloadButton}" /> |
130 | 131 | </i:Interaction.Behaviors> |
131 | 132 |
|
132 | 133 | </DataGrid> |
|
135 | 136 |
|
136 | 137 | <TabItem Header="Extended 2"> |
137 | 138 | <DockPanel> |
138 | | - <TextBlock DockPanel.Dock="Top" Margin="10" TextWrapping="WrapWithOverflow"> |
139 | | - <Run>This tab shows how to customize the filters in XAML when using explicit generated columns. Read the comments in the XAML for details.</Run><LineBreak/> |
140 | | - <Run>Overrides the icon template to show an orange filter symbol.</Run> |
141 | | - </TextBlock> |
| 139 | + <DockPanel DockPanel.Dock="Top" Margin="10"> |
| 140 | + <Button DockPanel.Dock="Right" VerticalAlignment="Top" Padding="5,2" Click="ClearIpsum_Click">Clear Ipsum</Button> |
| 141 | + <TextBlock TextWrapping="WrapWithOverflow"> |
| 142 | + <Run>This tab shows how to customize the filters in XAML when using explicit generated columns. Read the comments in the XAML for details.</Run><LineBreak /> |
| 143 | + <Run>Overrides the icon template to show an orange filter symbol.</Run> |
| 144 | + </TextBlock> |
| 145 | + </DockPanel> |
142 | 146 | <DataGrid ItemsSource="{Binding Source={StaticResource SortedItems}}" AutoGenerateColumns="False" FrozenColumnCount="2" |
143 | 147 | dgx:DataGridFilter.GlobalFilter="{Binding ExternalFilter}" |
144 | 148 | dgx:DataGridFilter.IsAutoFilterEnabled="True" |
145 | 149 | dgx:Tools.ApplyInitialSorting="True" |
146 | 150 | dgx:DataGridFilter.FilterEvaluationDelay="0:0:0"> |
147 | 151 | <i:Interaction.Behaviors> |
148 | | - <dgx:ExtendedStarSizeBehavior/> |
149 | | - <dgx:BeginEditOnCtrlEnterBehavior/> |
| 152 | + <dgx:ExtendedStarSizeBehavior /> |
| 153 | + <dgx:BeginEditOnCtrlEnterBehavior /> |
150 | 154 | </i:Interaction.Behaviors> |
151 | 155 |
|
152 | 156 | <!-- Override the default styles for some columns... --> |
153 | 157 | <dgx:ColumnStyles.DefaultColumnStyles> |
154 | 158 | <dgx:DataGridColumnStyleCollection> |
155 | | - <dgx:DataGridColumnStyle ColumnType="DataGridComboBoxColumn" EditingElementStyle="{StaticResource DataGridComboBoxStyle}"/> |
156 | | - <dgx:DataGridColumnStyle ColumnType="DataGridTextColumn" ElementStyle="{StaticResource DataGridTextBlockStyle}"/> |
| 159 | + <dgx:DataGridColumnStyle ColumnType="DataGridComboBoxColumn" EditingElementStyle="{StaticResource DataGridComboBoxStyle}" /> |
| 160 | + <dgx:DataGridColumnStyle ColumnType="DataGridTextColumn" ElementStyle="{StaticResource DataGridTextBlockStyle}" /> |
157 | 161 | </dgx:DataGridColumnStyleCollection> |
158 | 162 | </dgx:ColumnStyles.DefaultColumnStyles> |
159 | 163 |
|
|
192 | 196 | <DataGridTextColumn Header="Integer/Custom" |
193 | 197 | Binding="{Binding Index, Mode=OneWay}" |
194 | 198 | Width="*" |
195 | | - dgx:DataGridFilterColumn.Template="{StaticResource IntegerFilter}" |
196 | | - /> |
| 199 | + dgx:DataGridFilterColumn.Template="{StaticResource IntegerFilter}" /> |
197 | 200 | <!-- Hide the filter for this column. --> |
198 | | - <DataGridTextColumn Header="Text/No Filter" Binding="{Binding Column1}" Width="*" |
| 201 | + <DataGridTextColumn Header="Text/No Filter" Binding="{Binding Column5}" Width="*" |
199 | 202 | dgx:DataGridFilterColumn.IsFilterVisible="False" |
200 | 203 | dgx:Tools.IsMultilineEditingEnabled="True" |
201 | 204 | SortDirection="Descending" /> |
202 | 205 | <!-- Use the default filter for this column. --> |
203 | | - <DataGridTextColumn x:Name="Column2" Header="Text/Text" Binding="{Binding Column2, Mode=OneWay}" Width="*" /> |
204 | | - <!-- Use a simple combo box for filtering --> |
| 206 | + <DataGridTextColumn x:Name="Column2" Header="Text/Text" Binding="{Binding Column2, Mode=OneWay}" Width="*" /> |
| 207 | + <!-- Use a MultipleChoiceFilter for filtering --> |
205 | 208 | <DataGridComboBoxColumn Header="Text/Custom" SelectedValueBinding="{Binding Column5}" |
206 | 209 | Width="*" dgx:DataGridFilterColumn.Template="{StaticResource MultipleChoiceFilter}" |
207 | | - ItemsSource="{Binding Source={StaticResource ComboBoxSource}}"/> |
208 | | - <!-- Use a simple combo box for filtering, but override the editing element style --> |
| 210 | + ItemsSource="{Binding Source={StaticResource ComboBoxSource}}" /> |
| 211 | + <!-- Use a simple combo box for filtering --> |
209 | 212 | <DataGridComboBoxColumn Header="Text/Custom" SelectedValueBinding="{Binding Column5}" |
210 | 213 | Width="*" dgx:DataGridFilterColumn.Template="{StaticResource ComboboxFilter}" |
211 | | - ItemsSource="{Binding Source={StaticResource ComboBoxSource}}"> |
212 | | - <DataGridComboBoxColumn.ElementStyle> |
213 | | - <Style TargetType="ComboBox"> |
214 | | - <Setter Property="ItemTemplate"> |
215 | | - <Setter.Value> |
216 | | - <DataTemplate> |
217 | | - <TextBlock Text="{Binding InnerText}" Background="BlueViolet"/> |
218 | | - </DataTemplate> |
219 | | - </Setter.Value> |
220 | | - </Setter> |
221 | | - </Style> |
222 | | - </DataGridComboBoxColumn.ElementStyle> |
223 | | - </DataGridComboBoxColumn> |
| 214 | + ItemsSource="{Binding Source={StaticResource ComboBoxSource}}" /> |
224 | 215 | <!-- Use a special filter using a toggle button with a popup to enter more than one condition. --> |
225 | 216 | <DataGridTextColumn Header="Double/Custom" Binding="{Binding Probability, Mode=OneWay}" Width="*" |
226 | 217 | dgx:DataGridFilterColumn.Template="{StaticResource FilterWithPopup}" /> |
227 | 218 | <!-- A template column may contain everything, so we need to specify the SortMemberPath explicitly...--> |
228 | 219 | <DataGridTemplateColumn Header="Template" SortMemberPath="Probability"> |
229 | 220 | <DataGridTemplateColumn.CellTemplate> |
230 | 221 | <DataTemplate> |
231 | | - <TextBlock Margin="2" Text="{Binding Probability}"/> |
| 222 | + <TextBlock Margin="2" Text="{Binding Probability}" /> |
232 | 223 | </DataTemplate> |
233 | 224 | </DataGridTemplateColumn.CellTemplate> |
234 | 225 | </DataGridTemplateColumn> |
|
241 | 232 | <DataGrid x:Name="CopyPasteDataGrid" SelectionUnit="Cell" ItemsSource="{Binding Items}"> |
242 | 233 | <DataGrid.ContextMenu> |
243 | 234 | <ContextMenu> |
244 | | - <MenuItem Header="Copy" Click="Copy_Click"/> |
245 | | - <MenuItem Header="Paste" Click="Paste_Click"/> |
| 235 | + <MenuItem Header="Copy" Click="Copy_Click" /> |
| 236 | + <MenuItem Header="Paste" Click="Paste_Click" /> |
246 | 237 | </ContextMenu> |
247 | 238 | </DataGrid.ContextMenu> |
248 | 239 | </DataGrid> |
|
0 commit comments