Class MetaDataGrid
Provides a DataGrid with additional meta column.
Inheritance
Implements
Namespace: Sartorius.SAF.Presentation.Controls
Assembly: Sartorius.SAF.Presentation.Controls.dll
Syntax
public class MetaDataGrid : DataGrid, IAnimatable, ISupportInitialize, IFrameworkInputElement, IInputElement, IQueryAmbient, IContainItemStorage, IAddChild
Remarks
Use MetaColumnSortItems to provide sorting for the MetaColumn. The user can select these via a dropdown. You can use custom sorting via SortComparer when the underlying ItemsSource creates a ListCollectionView. You also can use a default sort descriptor by providing the PropertyName for the sorted property. If the underlying ItemsSource creates a BindingListCollectionView you cannot use a SortComparer.
You can either provide a template or template selector (MetaColumnTemplate and MetaColumnTemplateSelector) or use a default display by providing member names that should be shown as label and sub label (MetaColumnLabelPropertyName and MetaColumnSubLabelPropertyName). You can provide converters for these two members (MetaColumnLabelConverter and MetaColumnSubLabelConverter).
When you either provide MetaColumnEditingTemplate or MetaColumnEditingTemplateSelector the meta column becomes automatically editable.
When SelectionUnit is set to CellOrRowHeader and HeadersVisibility is set to not show the row header clicking on the meta column will select the whole row (this is done by laying the DataGridRowHeader over the meta column invisibly).
Examples
The following example shows how to use the default representation of the meta column by providing MetaColumnLabelPropertyName and MetaColumnSubLabelPropertyName and optional converters.
<SAF:MetaDataGrid ItemsSource="{Binding Samples}"
MetaColumnLabelPropertyName="Identifier"
MetaColumnSubLabelConverter="{StaticResource ToUpperStringConverter}"
MetaColumnSubLabelPropertyName="BatchName">
<SAF:MetaDataGrid.MetaColumnSortItems>
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by ID"
ListLabel="Sort by ID"
PropertyName="Identifier" />
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by Batch Name"
ListLabel="Sort by Batch Name"
PropertyName="BatchName" />
</SAF:MetaDataGrid.MetaColumnSortItems>
</SAF:MetaDataGrid>
The following example shows how to use the templating functionality for the meta column.
<SAF:MetaDataGrid ItemsSource="{Binding Samples}"
MetaColumnLabelPropertyName="Identifier"
MetaColumnSubLabelConverter="{StaticResource ToUpperStringConverter}"
MetaColumnSubLabelPropertyName="BatchName">
<SAF:MetaDataGrid.MetaColumnSortItems>
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by ID"
ListLabel="Sort by ID"
PropertyName="Identifier" />
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by Batch Name"
ListLabel="Sort by Batch Name"
PropertyName="BatchName" />
</SAF:MetaDataGrid.MetaColumnSortItems>
</SAF:MetaDataGrid>
<DataTemplate x:Key="MetaColumnTemplate">
<StackPanel Margin="19, 0, 20, 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<TextBlock Margin="0, 14, 0, 0"
FontSize="18"
FontWeight="Bold"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Style="{DynamicResource SAF_TextBlock}"
Text="{Binding Identifier}" />
<TextBlock Margin="0, 1, 0, 0"
FontSize="12"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Style="{DynamicResource SAF_TextBlock}"
Text="{Binding BatchName}" />
<TextBlock Margin="0, 1, 0, 0"
FontSize="8"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Style="{DynamicResource SAF_TextBlock}"
Text="{Binding Description}"
TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="MetaColumnEditTemplate">
<StackPanel Margin="19, 0, 20, 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<TextBox Margin="0, 14, 0, 0"
FontSize="18"
FontWeight="Bold"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Text="{Binding Identifier}" />
<TextBox Margin="0, 1, 0, 0"
FontSize="12"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Text="{Binding BatchName}" />
<TextBox Margin="0, 1, 0, 0"
FontSize="8"
Foreground="{Binding Foreground,
RelativeSource={RelativeSource AncestorType={x:Type DataGridCell}}}"
Text="{Binding Description}"
TextWrapping="Wrap" />
</StackPanel>
</DataTemplate>
The following example shows how to configure the MetaDataGrid to provide row selection by clicking the metaColumn. All other cells can be selected separately in this scenario.
<SAF:MetaDataGrid ItemsSource="{Binding Samples}"
SelectionUnit="CellOrRowHeader"
DefaultMetaColumnHeaderLabel="Samples"
MetaColumnTemplate="{StaticResource MetaColumnTemplate}"
MetaColumnEditingTemplate="{StaticResource MetaColumnEditTemplate}">
<SAF:MetaDataGrid.MetaColumnSortItems>
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by ID"
ListLabel="Sort by ID"
PropertyName="Identifier" />
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by Batch Name"
ListLabel="Sort by Batch Name"
PropertyName="BatchName" />
<SAF:MetaColumnSortItem HeaderLabel="Samples sorted by Description"
ListLabel="Sort by Description"
PropertyName="Description" />
</SAF:MetaDataGrid.MetaColumnSortItems>
</SAF:MetaDataGrid>
Constructors
View SourceMetaDataGrid()
Initializes a new instance of the MetaDataGrid class.
Declaration
public MetaDataGrid()
Fields
View SourceDefaultMetaColumnHeaderLabelProperty
Dependency Property of the default meta column header label property
Declaration
public static readonly DependencyProperty DefaultMetaColumnHeaderLabelProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
DetailViewRowStyleProperty
Dependency Property of the detail view row style property.
Declaration
public static readonly DependencyProperty DetailViewRowStyleProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
DetailsBorderBrushProperty
Identifies the DependencyProperty for DetailsBorderBrush.
Declaration
public static readonly DependencyProperty DetailsBorderBrushProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
DetailsBorderThicknessProperty
Identifies the DependencyProperty for DetailsBorderThickness.
Declaration
public static readonly DependencyProperty DetailsBorderThicknessProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
IsDetailRowViewVisibleProperty
Dependency Property of the is detail row view visible property
Declaration
public static readonly DependencyProperty IsDetailRowViewVisibleProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
IsMetaColumnIconVisibleProperty
The Dependency Property of the IsMetaColumnIconVisible property. Gets or sets a value indicating whether the meta data icon is visible.
Declaration
public static readonly DependencyProperty IsMetaColumnIconVisibleProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnBorderVisibilityProperty
Identifies the DependencyProperty for the MetaColumnBorderVisibility.
Declaration
protected static readonly DependencyProperty MetaColumnBorderVisibilityProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnCellStyleProperty
Identifies the DependencyProperty for MetaColumnCellStyle.
Declaration
public static readonly DependencyProperty MetaColumnCellStyleProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnEditingTemplateProperty
Identifies the DependencyProperty for MetaColumnEditingTemplate.
Declaration
public static readonly DependencyProperty MetaColumnEditingTemplateProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnEditingTemplateSelectorProperty
Identifies the DependencyProperty for MetaColumnEditingTemplateSelector.
Declaration
public static readonly DependencyProperty MetaColumnEditingTemplateSelectorProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnIconStyleProperty
The Dependency Property of the DefaultMetaColumnIconStyle property. Gets or sets the default meta data icon ContentControl style.
Declaration
public static readonly DependencyProperty MetaColumnIconStyleProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnMaxWidthProperty
Identifies the DependencyProperty for MetaColumnMinWidth.
Declaration
public static readonly DependencyProperty MetaColumnMaxWidthProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnMinWidthProperty
Identifies the DependencyProperty for MetaColumnMinWidth.
Declaration
public static readonly DependencyProperty MetaColumnMinWidthProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnSortItemsProperty
The Dependency Property of the MetaColumnSortItems property. Gets or sets the meta data sort items source.
Declaration
public static readonly DependencyProperty MetaColumnSortItemsProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnTemplateProperty
Identifies the DependencyProperty for MetaColumnTemplate.
Declaration
public static readonly DependencyProperty MetaColumnTemplateProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnTemplateSelectorProperty
Identifies the DependencyProperty for MetaColumnTemplateSelector.
Declaration
public static readonly DependencyProperty MetaColumnTemplateSelectorProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
MetaColumnWidthProperty
Identifies the DependencyProperty for MetaColumnWidth.
Declaration
public static readonly DependencyProperty MetaColumnWidthProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
SelectedMetaColumnSortItemProperty
The Dependency Property of the SelectedMetaColumnSortItem property. Gets or sets the selected meta data sort item.
Declaration
public static readonly DependencyProperty SelectedMetaColumnSortItemProperty
Field Value
| Type | Description |
|---|---|
| DependencyProperty |
Properties
View SourceDefaultMetaColumnHeaderLabel
Gets or sets the default meta column header label.
Declaration
public string DefaultMetaColumnHeaderLabel { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
DetailViewRowStyle
Gets or sets the detail view row style.
Declaration
public Style DetailViewRowStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| Style |
Remarks
The style target type is of ContentControl. The Height of the Style has to set explicitly. Otherwise the animation cannot determine the final height.
DetailsBorderBrush
Gets or sets the border brush of the details grid.
Declaration
public Brush DetailsBorderBrush { get; set; }
Property Value
| Type | Description |
|---|---|
| Brush | The detail border brush. |
DetailsBorderThickness
Gets or sets the border thickness of the details grid.
Declaration
public Thickness DetailsBorderThickness { get; set; }
Property Value
| Type | Description |
|---|---|
| Thickness | The detail border thickness. |
IsDetailRowViewVisible
Gets or sets a value indicating whether the detail row view is visible.
Declaration
public bool IsDetailRowViewVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsMetaColumnIconVisible
Gets or sets a value indicating whether the meta data icon is visible.
Declaration
public bool IsMetaColumnIconVisible { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
MetaColumnBorderVisibility
Gets a value indicating whether the meta column border is visible.
Declaration
protected Visibility MetaColumnBorderVisibility { get; }
Property Value
| Type | Description |
|---|---|
| Visibility |
|
MetaColumnCellStyle
Gets or sets the meta column cell style.
Declaration
public Style MetaColumnCellStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| Style |
MetaColumnEditingTemplate
Gets or sets the DataTemplate used for editing in the MetaColumn.
Declaration
public DataTemplate MetaColumnEditingTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTemplate |
Remarks
If this template and MetaColumnEditingTemplateSelector are not set the MetaColumn cannot be edited.
MetaColumnEditingTemplateSelector
Gets or sets the DataTemplateSelector used to select the template for editing in the MetaColumn.
Declaration
public DataTemplateSelector MetaColumnEditingTemplateSelector { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTemplateSelector |
Remarks
If this selector and MetaColumnEditingTemplate are not set the MetaColumn cannot be edited.
MetaColumnIconStyle
Gets or sets the default meta data icon ContentControl style.
Declaration
public Style MetaColumnIconStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| Style |
Remarks
The style target type is of ContentControl.
MetaColumnLabelConverter
Gets or sets the meta column label converter.
Declaration
public IValueConverter MetaColumnLabelConverter { get; set; }
Property Value
| Type | Description |
|---|---|
| IValueConverter |
Remarks
If NULL the ToUpperStringConverter is used.
MetaColumnLabelPropertyName
Gets or sets the name of the meta column label property.
Declaration
public string MetaColumnLabelPropertyName { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The name of the meta column label property. |
MetaColumnMaxWidth
Gets or sets the maximum width of the meta column.
Declaration
public double MetaColumnMaxWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double | The maximum width of the meta column. |
MetaColumnMinWidth
Gets or sets the minimum width of the meta column.
Declaration
public double MetaColumnMinWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| double | The minimum width of the meta column. |
MetaColumnSortItems
Gets or sets the meta data sort items source.
Declaration
[SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Can be used in Xaml.")]
public ObservableCollection<MetaColumnSortItem> MetaColumnSortItems { get; set; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<MetaColumnSortItem> |
MetaColumnSubLabelConverter
Gets or sets the meta column sub label converter.
Declaration
public IValueConverter MetaColumnSubLabelConverter { get; set; }
Property Value
| Type | Description |
|---|---|
| IValueConverter |
Remarks
If NULL no converter is used.
MetaColumnSubLabelPropertyName
Gets or sets the name of the meta column sub label property.
Declaration
public string MetaColumnSubLabelPropertyName { get; set; }
Property Value
| Type | Description |
|---|---|
| string | The name of the meta column sub label property. |
MetaColumnTemplate
Gets or sets the DataTemplate for the MetaColumn.
Declaration
public DataTemplate MetaColumnTemplate { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTemplate |
Remarks
If the template and MetaColumnTemplateSelector are not set MetaColumnLabelPropertyName, MetaColumnLabelConverter, MetaColumnSubLabelPropertyName and MetaColumnSubLabelConverter are used.
MetaColumnTemplateSelector
Gets or sets the DataTemplateSelector used to select the template for the MetaColumn.
Declaration
public DataTemplateSelector MetaColumnTemplateSelector { get; set; }
Property Value
| Type | Description |
|---|---|
| DataTemplateSelector |
Remarks
If the selector and MetaColumnTemplate are not set MetaColumnLabelPropertyName, MetaColumnLabelConverter, MetaColumnSubLabelPropertyName and MetaColumnSubLabelConverter are used.
MetaColumnWidth
Gets or sets the width of the meta column.
Declaration
public DataGridLength MetaColumnWidth { get; set; }
Property Value
| Type | Description |
|---|---|
| DataGridLength | The width of the meta column. |
SelectedMetaColumnSortItem
Gets or sets the selected meta data sort item.
Declaration
public MetaColumnSortItem SelectedMetaColumnSortItem { get; set; }
Property Value
| Type | Description |
|---|---|
| MetaColumnSortItem |
Methods
View SourceOnApplyTemplate()
applies the template for the DataGrid
Declaration
public override void OnApplyTemplate()
Overrides
View SourceOnItemsSourceChanged(IEnumerable, IEnumerable)
Invoked when the ItemsSource property changes.
Declaration
protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable | oldValue | The old source. |
| IEnumerable | newValue | The new source. |
Overrides
View SourceOnLoadingRow(DataGridRowEventArgs)
Raises the LoadingRow event.
Declaration
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Parameter 'e' is never null.")]
protected override void OnLoadingRow(DataGridRowEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridRowEventArgs | e | The data for the event. |
Overrides
View SourceOnRenderSizeChanged(SizeChangedInfo)
Raises the SizeChanged event, using the specified information as part of the eventual event data.
Declaration
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| SizeChangedInfo | sizeInfo | Details of the old and new size involved in the change. |
Overrides
View SourceOnSorting(DataGridSortingEventArgs)
Raises the Sorting event.
Declaration
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Parameter 'eventArgs' is never null.")]
protected override void OnSorting(DataGridSortingEventArgs eventArgs)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridSortingEventArgs | eventArgs | The data for the event. |
Overrides
View SourceOnUnloadingRow(DataGridRowEventArgs)
Raises the UnloadingRow event.
Declaration
[SuppressMessage("Design", "CA1062:Validate arguments of public methods", Justification = "Parameter 'e' is never null.")]
protected override void OnUnloadingRow(DataGridRowEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| DataGridRowEventArgs | e | The data for the event. |