I have an unbound field which I'm assigning the ContentTemplate property of the CellValuePresenter to some Data Template I've defined. How do I bind the data template to the data of the unbound field? Currently what I've tried shows no value (blank).
This is my field:
<igDP:UnboundField Name="ServiceDate" Label="Service Date" BindingMode="TwoWay" BindingPath="ServiceDateUTC"
Visibility="Visible" >
<igDP:UnboundField.Settings >
<igDP:FieldSettings LabelWidth="100" CellWidth="100" AllowEdit="True"
InvalidValueBehavior="RetainValue" EditorType="{x:Type igEditors:XamDateTimeEditor}">
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}" >
<Setter Property="ContentTemplate">
<Setter.Value>
<MultiBinding Converter="{StaticResource IndexToTemplateConverter}">
<MultiBinding.Bindings>
<Binding RelativeSource="{RelativeSource Self}"/>
<Binding Path="Record.Index" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordCellArea}}"/>
</MultiBinding.Bindings>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
and this is the DataTemplate I'm assigning (through the converter):
<DataTemplate x:Key="dateTimeTemplate">
<igEditors:XamDateTimeEditor
BorderBrush="Transparent"
IsInEditMode="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=IsInEditMode}"
Value="{Binding Path=Record.DataItem.ServiceDateUTC, Mode=TwoWay, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:DataRecordCellArea}}}"
AutoFillDate="Year" DropDownButtonDisplayMode="Always" Mask="{}{date}" />
</DataTemplate>
Hello,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
In the code that you provided, is it possible to pass Record.DataItem.ServiceDateUTC instead of Record.Index? I tried that but what I got for the value was DependencyProperty.UnsetValue.
Hello Adrian,
Thank you for your reply. I have been looking into your question and you can add a check for DependencyProperty.UnsetValue at the beginning of the converter and it will work as expected with the DataItem:
if (values[0] == DependencyProperty.UnsetValue
|| values[1] == DependencyProperty.UnsetValue)
return Binding.DoNothing;
I have modified the sample application to show how you can use the DateTime property of the DataItem to show different ContentTempaltes for the CellValuePresenter.
Please let me know if you need any further assistance on the matter.
Krasimir, MCPD
Developer Support Supervisor - XAML