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 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.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
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,
I am just checking if you require any further assistance on the matter.
Krasimir
Developer Support Engineer
Thank you for your post. I have created a sample application for you, using the code snippet that you have provided me with as basis and the XamDateTimeEditor in the DataTemplate seems to update the value of the cell that corresponds to editor, when you change the date in the XamDateTimeEditor. I have added the UnboundField and a Field after it in order to demonstrates that the underlying data is update. I have tested the sample application using both the RTM and the latest service release of version 11.2 with the same result. I am attaching the sample application and a screenshot of the behavior that I am getting.
Please let me know if you can reproduce the same behavior with my sample application or I have misunderstood you in an way.