As mentioned in this tutorial's introduction: use styles to change an element's appearance and modify simple behaviors; use templates to change an element's layout, visual structure, and more complex behaviors.
Table 1: Elements to style
Element to style | What we will be changing |
---|---|
DataGridControl | Background, Foreground, and FontFamily |
RowSelectorPane | Background and Foreground |
Row | SelectionBackground and SelectionForeground |
ColumnManagerRow | Background, BorderBrush, and BorderThickness |
ColumnManagerCell | Padding |
HierarchichalGroupByControl | Background and Foreground |
HierarchicalGroupByItem | Background, BorderBrush, and BorderThickness |
GroupHeaderControl | Background, BorderThickness, and BorderBrush |
TableView | HorizontalGridLineBrush and VerticalGridLineThickness |
groupByConnectionLinePen resource ( GroupByControl.ConnectionLinePen) |
Providing a new Pen |
dropMarkPen resource ( ViewBase.DropMarkPen) |
Providing a new Pen. The drop-mark pen is used to identify the location where a column will be dropped when it is being dragged. |
Element to template | What we will be changing |
---|---|
RowSelector | Custom separator lines and change the background when the mouse is pressed |
ColumnManagerCell | Change the background when the mouse is pressed Custom separator lines Change the color of the sort glyph |
Styles are usually, but not necessarily, defined in the resources of an element, which determines the scope of where that particular style can be used. For example, providing a style for a button in the resources of an application indicates that all buttons in the application that wish to use the style may do so. If a style is provided in a more limited scope (e.g., in a Window's resources) then only the elements defined in the Window can use the style.
The x:Key and TargetType properties of a style determine how a style is applied to the elements in the same scope. If only a key is provided, all elements that wish to use the style must explicitly reference it using a StaticResource or DynamicResource markup extension. If only a target type is provided, all elements with the same type will automatically inherit the property values of the style. If a style provides both a key and a target type, the style will only be applied to the elements of the same target type that explicitly reference it by its key.
Now that you have finished digesting what you just read, let's go to the next part where we will apply new styles and templates to the elements listed above.