I want to replace the default nested content with datacards. Is this possible? how do I do the binding?
I have modified this bit so far from the default template "DataPresenterGeneric_Express.xaml"
<Grid
x:Name="PART_NestedContentSite"
RenderTransform="{TemplateBinding FixedNearElementTransform}"
Grid.Row="1"
Grid.Column="1"
Visibility="Collapsed">
<ContentControl
x:Name="ncpVisual"
RenderTransform="{TemplateBinding ScrollableElementTransform}"
Opacity="0"
TextBlock.Foreground="{DynamicResource {ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelForeground}}"
Margin="{TemplateBinding Padding}">
<StackPanel>
<Label Content="Easy" />
<igDP:XamDataCards BindToSampleData="True" />
</StackPanel>
</ContentControl>
</Grid>
But I can't figure out what to bind the XamDataCards to? . . .
Hello,
The nested content control is a RecordListControl, which holds the nested records. You would have to bind the XamDataCards directly to the DataItem. Here is the binding expression that you can use in the template of the ExpandableFieldRecordPresenter:
<igDP:XamDataCards DataSource="{Binding Path=Record.ParentDataRecord.DataItem.Relatives, RelativeSource{RelativeSource TemplatedParent}}"/>
There is another way to achieve this. You could use a CellValuePresenter style and custom positioning of the nested field. For example :
<igDP:Field Name="Relatives" IsExpandable="False" Row="1" Column="0" ColumnSpan="6"> <igDP:Field.Settings> <igDP:FieldSettings CellValuePresenterStyle="{StaticResource RelativesStyle}"/> </igDP:Field.Settings></igDP:Field>
where the custom style is :
<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="RelativesStyle"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <igDP:XamDataCards DataSource="{Binding DataItem.Relatives}" x:Name="content"/> <ControlTemplate.Triggers> <DataTrigger Binding="{Binding IsExpanded}" Value="False"> <Setter Property="Visibility" Value="Collapsed" TargetName="content"/> </DataTrigger> <DataTrigger Binding="{Binding IsExpanded}" Value="True"> <Setter Property="Visibility" Value="Visible" TargetName="content"/> </DataTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
I have attached a sample demonstrating these two approaches.
Anyone take a look at this? Still pounding my head against the wall