We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Cell item template binding

Thread ID:

Created:

Updated:

Platform:

Replies:

108679 May 7,2013 05:05 AM May 27,2014 09:17 AM WPF 3
loading
Tags: GridDataControl
thomas tomanek
Asked On May 7, 2013 05:05 AM

Hi,

Is there a way to specify a binding in a cell item template that references what would logically be the datacontext of the row (although looking at the visual tree I don't see an actual row object). What I want is a cell template that combines the values from a few different objects on the data context but at the moment I'm stuck binding only to the CellBoundValue.

I'm looking at migrating from Xceed's grid, but in that grid I can easily specify a relative source binding from the cell template to grab the datacontext of the row.

Hope that makes sense,
Cheers

Divya A [Syncfusion]
Replied On May 14, 2013 02:38 AM

Hi Thomas,

 

You can bind the entire Record of the particular row to the DataTemplate objects by binding Record.Data. You can also access the corresponding Column value by its MappingName as in the following code snippet.

 

 

Code Snippet:

 

  <syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">
      <syncfusion:GridDataVisibleColumn.CellItemTemplate>
           <DataTemplate>
              <StackPanel Orientation="Horizontal">
                 <TextBlock Text="{Binding Record.Data.CustomerID}" Width="75"/>
                 <TextBlock Text="{Binding Record.Data.CustomerName}" Width="75"/>
              </StackPanel>
           </DataTemplate>
      </syncfusion:GridDataVisibleColumn.CellItemTemplate>
  </syncfusion:GridDataVisibleColumn>

 

 

Please let us know if you have any concerns.

 

Regards,

Divya.


Michael Cheng
Replied On April 10, 2014 05:02 PM

What does this mean?
"You can also access the corresponding Column value by its MappingName as in the following code snippet."

In the data template?

Ganesan V [Syncfusion]
Replied On May 27, 2014 09:17 AM

Hi Thomas,

 

Thank you for your patience.

 

If you want to display the CellBoundValue to the template column, you can display it by using the CellBoundValue , Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">

      <syncfusion:GridDataVisibleColumn.CellItemTemplate>

           <DataTemplate>

              <StackPanel Orientation="Horizontal">

                 <TextBlock Text="{Binding Path=CellBoundValue}" Width="75"/>

              </StackPanel>

           </DataTemplate>

      </syncfusion:GridDataVisibleColumn.CellItemTemplate>

  </syncfusion:GridDataVisibleColumn>

 

And also If you want to display the corresponding column value to the template column, you can use the Record.Data.MappingName. Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">

      <syncfusion:GridDataVisibleColumn.CellItemTemplate>

           <DataTemplate>

              <StackPanel Orientation="Horizontal">

                 <TextBlock Text="{Binding Record.Data.ProductID}" Width="75"/>

              </StackPanel>

           </DataTemplate>

      </syncfusion:GridDataVisibleColumn.CellItemTemplate>

  </syncfusion:GridDataVisibleColumn>

 

If you want to display the other property value in column, you can bind as Record.Data.PropertyName. Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">
      <syncfusion:GridDataVisibleColumn.CellItemTemplate>
           <DataTemplate>
              <StackPanel Orientation="Horizontal">
                 <TextBlock Text="{Binding Record.Data.CustomerID}" Width="75"/>
                 <TextBlock Text="{Binding Record.Data.CustomerName}" Width="75"/>
              </StackPanel>
           </DataTemplate>
      </syncfusion:GridDataVisibleColumn.CellItemTemplate>
  </syncfusion:GridDataVisibleColumn>

 

Please let us know if you have any queries,

 

Regards,

Ganesan V

 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;