ColumnBase.GetHeaderPresenterType(DependencyObject) Method
Gets the value of the ColumnBase.HeaderPresenterType attached property for a specified DependencyObject.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.2.Core.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
element | DependencyObject | The element from which the property value is read. |
Returns
Type | Description |
---|---|
HeaderPresenterType | The ColumnBase.HeaderPresenterType property value for the element. |
Example
This example adds the Click button to the Id column’s header when it is displayed in the Column Chooser.
<Window.Resources>
<DataTemplate x:Key="columnChooserTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}"/>
<Button Content="Click" Margin="5,0,0,0"/>
</StackPanel>
</DataTemplate>
<local:HeaderTemplateSelector x:Key="headerTemplateSelector"
ColumnChooserTemplate="{StaticResource columnChooserTemplate}"/>
</Window.Resources>
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew">
<dxg:GridControl.View>
<dxg:TableView x:Name="view" ColumnHeaderTemplateSelector="{StaticResource headerTemplateSelector}"/>
</dxg:GridControl.View>
</dxg:GridControl>
public class HeaderTemplateSelector : DataTemplateSelector {
public DataTemplate ColumnChooserTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
if (ColumnBase.GetHeaderPresenterType(container) == HeaderPresenterType.ColumnChooser && (string)item == nameof(Item.Id))
return ColumnChooserTemplate;
return base.SelectTemplate(item, container);
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetHeaderPresenterType(DependencyObject) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.