Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Binding the property in DisplayTemplate with property other than the value to be displayed.
posted

<ig:XamDataGrid Grid.ColumnSpan="2" DataSource="{Binding StudentData}">
<ig:XamDataGrid.FieldLayouts>
<ig:FieldLayout>
<ig:TemplateField Label="Marks" Name="StudentMarks" AllowEdit="True" AllowGroupBy="False" DisplayTemplate="{StaticResource FieldDisplayTemplate}" EditTemplate="{StaticResource FieldEditTemplate}"/>
</ig:FieldLayout>
</ig:XamDataGrid.FieldLayouts>
</ig:XamDataGrid>

Following are the templates

<DataTemplate x:Key="EditableFieldDisplayTemplate">
    <TextBlock Text="{igEditors:TemplateEditorValueBinding}"   ToolTip={Binding DataItem.Staus}
     HorizontalAlignment="Right"/>
</DataTemplate>
<DataTemplate x:Key="EditableFieldEditTemplate">
   
     <igEditors:XamNumericEditor Value="{igEditors:TemplateEditorValueBinding}" SpinButtonDisplayMode="Always" SpinIncrement="50"/>

</DataTemplate>

SudentData is a collection of  Class Student which has two properties : Marks and Status

Staus in the tooltip is not visible , how can I access the Status Property inside the datatemplate of display template?

  • 28970
    Verified Answer
    Offline posted

    Hello Jatin,

    I have been investigating the behavior you are looking to achieve, and the reason that your ToolTip binding is not working is because the elements that exist in the DisplayTemplate do not have a DataContext of the underlying record. Their DataContext is the underlying value to the cell of the record in the TemplateField.

    That said, there is an alternative binding method that you can use in the TemplateField by binding to the attached (igEdit:TemplateEditor.Editor) property, as shown in this documentation article.

    Following this, your binding should look something like the following:

    ToolTip="{Binding Path=(igEdit:TemplateEditor.Editor).DataContext.DataItem.Status, RelativeSource={RelativeSource Self}}"

    Please let me know if you have any other questions or concerns on this matter.