wpf-devexpress-dot-xpf-dot-pivotgrid-dot-pivotgridcontrol-c06cdb90.md
Gets or sets the data template selector which chooses a template based on the field’s type. This is a dependency property.
Namespace : DevExpress.Xpf.PivotGrid
Assembly : DevExpress.Xpf.PivotGrid.v25.2.dll
NuGet Package : DevExpress.Wpf.PivotGrid
public DataTemplateSelector FieldGeneratorTemplateSelector { get; set; }
Public Property FieldGeneratorTemplateSelector As DataTemplateSelector
| Type | Description |
|---|---|
| DataTemplateSelector |
A DataTemplateSelector object that is a field template selector.
|
The DevExpress WPF PivotGridControl supports field binding. The Pivot Grid can be bound to a collection of objects containing field settings, described in a Model or ViewModel. The PivotGridControl generates fields based on field templates. Using a single template, you can create an unlimited number of fields in an unlimited number of Pivot Grid controls.
To choose the required field template, use the Data Template Selector assigned to the FieldGeneratorTemplateSelector property.
public class FieldTemplateSelector : DataTemplateSelector {
public override DataTemplate SelectTemplate(object item, DependencyObject container) {
Field field = (Field)item;
if(field.Interval == FieldGroupInterval.DateYear) {
return (DataTemplate)((Control)container).FindResource("IntervalFieldTemplate");
}
return (DataTemplate)((Control)container).FindResource("DefaultFieldTemplate");
}
}
}
Public Class FieldTemplateSelector
Inherits DataTemplateSelector
Public Overrides Function SelectTemplate(ByVal item As Object, ByVal container As DependencyObject) As DataTemplate
Dim field As Field = CType(item, Field)
If field.Interval = FieldGroupInterval.DateYear Then
Return CType((CType(container, Control)).FindResource("IntervalFieldTemplate"), DataTemplate)
End If
Return CType((CType(container, Control)).FindResource("DefaultFieldTemplate"), DataTemplate)
End Function
End Class
}
<Grid>
<dxpg:PivotGridControl x:Name="pivotGridControl1"
DataSource="{Binding Data, Source={StaticResource TypedSimpleSource}}"
FieldsSource="{Binding Fields }"
FieldGeneratorTemplateSelector="{StaticResource FieldTemplateSelector}"
</dxpg:PivotGridControl>
</Grid>
To learn more, see Binding to a Collection of Fields.
See Also