I want to create a new template for a datarecord presenter, but I'm having trouble getting anything to show up. I see my border, but none of the data is inside it. This is a really simple style for reference.
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="Margin" Value="0,1,0,10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:DataRecordPresenter}">
<Border BorderBrush="Blue" BorderThickness="2" Background="LightBlue" CornerRadius="10,0,10,0">
<StackPanel>
<ContentPresenter Name="PART_HeaderContentSite" MinHeight="20" MinWidth="50"/>
<ContentPresenter Name="PART_RecordContentSite" MinHeight="20" MinWidth="50"/>
<ContentPresenter Name="PART_NestedContentSite" MinHeight="20" MinWidth="50"/>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Hi,
You're on the right track; however, your ContentPresenter's are missing some vital binding statements.
<ContentPresenter Name="PART_HeaderContentSite" MinHeight="20" MinWidth="50" Content="{TemplateBinding HeaderContent}" />
<ContentPresenter x:Name="PART_RecordContentSite" Content="{TemplateBinding DataContext}" ContentTemplate="{TemplateBinding RecordContentAreaTemplate}" MinHeight="20" MinWidth="50" />
Finally, you also need to add a Trigger to the ControlTemplate that hides the PART_RecordContentSite if the ShouldDisplayNestedContent property is Fals;.otherwise, your field headers will display record content.
<ControlTemplate.Triggers>
<Trigger Property="ShouldDisplayRecordContent" Value="False">
<Setter TargetName="PART_RecordContentSite" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
The best way to create templates for Infragistics' controls is to start with the default styles. The default styles (XAML files) are automatically installed when you install our product. The default location where you can find the files is c:\program files\infragistics\NetAdvantage for WPF [year] Vol. [#]\DefaultStyles\.
Hope that helps :)
Thanks, that definately gets me closer to where I want to go. One other question is how do I use this style if it's not the default style? I can't find a place on xamDataGrid to set RecordPresenterStyle.