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.

Data Template Cell & Multi-Cell Selection

Thread ID:





92349 Jan 7,2010 12:58 PM Nov 28,2011 06:27 AM WPF 15
Tags: GridControl
Puthirak OM
Asked On January 7, 2010 12:58 PM


I've created my own Data Template Cell to be used in a GridControl,
using your sample DataTemplateCell_2008 as a starter. It works great.

But i cannot do a multi-cell selection (with the mouse or the keyboard) when the starter cell's type is my Data Template cell type.

In your sample, the multi-cell selection works.

Here's my Data Template definition:

Background="{Binding Converter={StaticResource CellDataBarGridBackgroundConvertor}}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

Height="{Binding Mode=OneWay, ElementName=CellDataBarGrid, Path=ActualHeight, Converter={StaticResource CellDataBarHeightConvertor}}"
BorderBrush="{Binding Mode=OneWay, Converter={StaticResource CellDataBarBorderConvertor}}"
HorizontalAlignment="Left" VerticalAlignment="Center"
Background="{Binding Mode=OneWay, Converter={StaticResource CellDataBarBackgroundConvertor}}">

BorderThickness="0" Margin="0" BorderBrush="Transparent"
Width="{Binding ElementName=CellDataBarGrid, Path=ActualWidth}"
Height="{Binding ElementName=CellDataBarGrid, Path=ActualHeight}">
Text="{Binding Mode=OneWay, Converter={StaticResource CellDataBarValueConvertor}}"
Visibility="{Binding Mode=OneWay, Converter={StaticResource CellDataBarValueVisibilityConvertor}}"
VerticalAlignment="{Binding Mode=OneWay, Converter={StaticResource CellDataBarValueVerticalAlignmentConvertor}}"
HorizontalAlignment="{Binding Mode=OneWay, Converter={StaticResource CellDataBarValueHorizontalAlignmentConvertor}}"
TextTrimming="CharacterEllipsis" TextWrapping="NoWrap"
Background="Transparent" Padding="0" Margin="0"/>

Reportive SA

Mohamed Suhaib Fahad A. [Syncfusion]
Replied On January 13, 2010 04:37 AM

Hi Puthirak,

Thanks for using Syncfusion products. When defining custom DataTemplate's the mouse behaviors get handled internally with the Template's control, and this would not work with the Mouse behavior architecture of the grid. However, we have an Attached property that you can use to allow Mouse being handled by the base root object (Grid) itself(syncfusion:VisualContainer.WantsMouseInput="true"). In our samples too we have used this to allow mouse behaviors,



Let us know if this helps.


Puthirak OM
Replied On January 13, 2010 05:17 AM


By setting the property on the grid :


It works.


Reportive SA

Mohamed Suhaib Fahad A. [Syncfusion]
Replied On January 14, 2010 12:14 AM

Hi Puthirak,

Thanks for the details. You can update us if you have anything else.


Jean-Marc DUHEN
Replied On March 10, 2010 06:03 AM


Is there still a problem with multiple selection and datatemplates ?

For example :

.. the multiple selection does not work.

Thank you

Ganesan K [Syncfusion]
Replied On March 17, 2010 04:47 PM

Hi Jean,

We fixed this issue in our latest source. Please create a Direct trac incident to get latest assemblies.

Please let us know if you need any more details.


Nickolas Muson
Replied On July 15, 2011 11:41 AM

I know this a long time since this was an active issue, but I have a question: No matter what I do with the grid and the datatemplates, I cannot change the way the cell selection works.

I have tried:
- Grid1.AllowSelection = None, or Cell, or Cell | Multi
- ListBoxSelectionMode="None"
- ListBoxModeAllowUIElementClick="False"
- AutoFocusCurrentItem="False"

and any number of combinations of
- syncfusion:VisualContainer.WantsMouseInput on the DataTemplates.

No matter what I do:
- The whole row gets selected with an orange bg when I select any cell
- The non-DataTemplated cells are a little darker orange when selected
- No multiselection of cells is possible
- The DataTemplated cols (Customer and Freight) cannot be selected without also putting them into edit mode.

My biggest problem right now is that I need to have cols with a CellItemTemplate, but that seems to break selection and multiselection. No matter what I do the cell goes into edit mode.

Rajasekar [Syncfusion]
Replied On July 19, 2011 09:04 AM

Hi Nickolas,

Sorry for the inconvenience caused.

You can perform cell selection by using the below code snippet,

this.dataGrid.ListBoxSelectionMode = GridSelectionMode.None;
this.dataGrid.AllowSelection = GridSelectionFlags.Cell;

For selection behaviour while editing the Datatemplate cells, you can clear the selection by using the below code snippet,

this.dataGrid.CurrentCellStartEditing += new Syncfusion.Windows.ComponentModel.GridCancelRoutedEventHandler(dataGrid_CurrentCellStartEditing);

void dataGrid_CurrentCellStartEditing(object sender, Syncfusion.Windows.ComponentModel.SyncfusionCancelRoutedEventArgs args)


< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS-325583311.zip >

Please let us know if you have any queries.


Nickolas Muson
Replied On July 20, 2011 01:52 PM

Wow, Rajasekar, I am very impressed with the quick response, and your code sample id excellent, thank you.

However, I did a little test with the sample code and was able to easily reproduce the problem I am still having. All I did was modify Window1.xaml (attached) to add the exact same validatedTextBoxStyle to the ShipCity and ShipCountry columns using the same technique you did on the Freight column (though I removed the rules obviously)

So now, with 3 templated textbox columns right next to each other, it seems impossible to multi-select the cells in those columns unless you extend the selection past the templated cols to include a "normal" col. In this example, for instance, unless you include the Order ID or Ship Country cols in the selection the templated cell remains in "edit mode" and no other cells get selected or added to the clipboard on CTRL-C.

This is a huge problem for me, because all my cells are templated, so there are no "normal" ones to select. Any suggestions?

Thanks again, Nick Muson


Rajasekar [Syncfusion]
Replied On July 21, 2011 08:53 AM

Hi Nickolas,

Sorry for the inconvenience, you cannot draw highlight selection on the data template cells, because data tempalte cells will contains seprate controls or many controls. In this scenario, selection will be applied but due to datatemplated cells it is not visible. In this scenario, you perform multiple row selection by using row headers. please check the attached sample and video,





Please note, The datatemplated cell contains textbox means, the selection will be broken by that corresponding textbox text selection.So In this scenario, you cannot perform multiple cell selection.


Nickolas Muson
Replied On July 21, 2011 11:19 AM

Thanks again Rajasekar

That is very disappointing news. Cell selection is pretty much a key part of any grid. It seems that the documentation should be more clear on this: you can have EITHER cell selection or cell templates, but not both. This is a pretty fatal flaw I think.

My main problem here is that I need to visually track "dirty" cells while the user is editing the grid, meaning an edited cell goes red until they commit all their changes (or manually un-do the cell edit), at which point it goes back to normal. There are some 60 columns per row that all need this functionality, and the Expression and Conditional Format columns don't cut it -- I need to be able to reference the Record.Data.IsDirty (or something like that) to set the bg color of the cell.

Can you think of another solution that will give me this functionality AND multi-cell selection? I could probably use QueryCellInfo to render changed cells differently, but that seems like a hack. One thing worth mentioning: I will be using a virtual GridControl to handle Excel-type formula support (but I haven't wired it up yet) so maybe that could be leveraged.

Also, another question: The GridDataControl columns support a CellItemTemplate and a CellEditItemTemplate, but all the samples and documentation mention is the CellItemTemplate. Could this somehow be leveraged to define a CellEditItemTemplate but not a CellItemTemplate, and control when the grid goes into "edit mode" more carefully? Either way, I am interested to see how the 2 different templates works -- is there any sample code available that uses CellEditItemTemplate?

I really have to come up with a solution for this problem with as little duct-tape as possible. The WPF functionality of the GridDataControl is kind of weak, but we're OK with that because we need the excel-type formula support, but if I have to hack cell selection then it might not be worth the large investment my company has to make to license the control.

I really appreciate all the support I've gotten from Syncfusion though, and that matters a lot too. Should I make this a DirectTrac case?

Nick Muson
Group One Trading

Rajasekar [Syncfusion]
Replied On July 22, 2011 07:32 AM

Hi Nick,

Thanks for your update.

We have prepared the sample based on your requirement, please find the sample in the below location,

Regarding CellEditItemTemplate and Color Change:

< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ColorChangeEditing1802164708.zip >

Regarding Formula Cell:

< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GC_FormulaCell-434236334.zip >

Regarding Multiple selection for DataTemplate Cells:

The corresponding multiple selection will done, but will be in background. Due to data templated cells, it is not invisible.

Please check the below video and sample,


< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Selection-1961866291.zip >


< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=MultipleSelection-786512819.zip >

Please let us know if you have any queries.


Nickolas Muson
Replied On July 22, 2011 11:58 AM

Speedy delivery, as usual, thanks again. I am not feeling like we're any closer to a solution here though.

Sample 1:
The tracking of a "dirty" cell I already know how to do using a similar technique. This re-affirms that I cannot get multi-cell selection using this templated cells.

Sample 2:
I already have this one, and it's an excellent demonstration, but unfortunately it's not relevant to my current problem

Sample 3:
This one was the most disheartening, really, because it's seems to prove that what I need to do is not possible with the GridDataControl. I cannot present an app to our users that selects cells without any visual indication that the cells are selected -- if they are "invisibly" selected then from a user's pov they are really not selected at all.

I have to decide ASAP whether this is a showstopper or not. Copying and pasting multiple cells is an absolute key requirement of the app, there's no way around it.

Can we escalate this to find a solution?

Rajasekar [Syncfusion]
Replied On July 25, 2011 11:34 AM

Hi Nick,

Thanks for your update.

Regarding Multiple cell Selection:

Once the cell enters in to the edit mode of any data templated cell means, you cannot perform multiple selection by dragging. Because, here selection will be control by that corresponding data templated control and also grid cannot predicted which controls is inside the data templated cell. But, you can achieve this multiple selection behavior for data templated cells by using CellItemtemplate and CellEdItItemTemplate and by setting syncfusion:VisualContainer.WantsMouseInput property as False like shown be.

Code snippet[XAML]

Name="customersCombo" Background="White"
SelectedValue="{Binding Path=CellBoundValue,Mode=TwoWay}"
ItemsSource="{Binding Path=Style.ItemsSource}"

For displaying the highlighted cell, you achieve by using the below code snippet,

Code Snippet[C#]

dataGrid.DrawSelectionOptions = GridDrawSelectionOptions.AlphaBlend;
dataGrid.HighlightSelectionAlphaBlend = Brushes.Red;

Regarding CopyPaste:

Once the data templated cell enters into edit mode, even though you select multiple cells in the grid , only the respective edit mode cell content will be copied to the clipboard. For instance, You can observe that behavior while debugging by using below code,


And also please note, In GridDatacontrol copy paste will be applied based on the DataType of the Mapping Name of the GridDataControl.

For your reference, please find sample and video in the below location,


< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS-1798639161.zip >


< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=DataTemplateMultiselect-1958411422.zip >

Similar query is posted in the incident #82877. For further calrification, please update your queries in the incident #82877 for better follow up.

Please let us know if you have any queries.


Replied On October 19, 2011 09:39 PM

I am using syncfusion. I have one problem with multi cell updation in data grid of wpf. I can select multi cell selection but I can not do multiple updation for those selected cells. say for example I have select R1 C2(Row 1 of cell 2), R1 Cell 10...so on my last cell selection which is R1C10 when I type text or number and hit enter that value goes to all selected cells(which are R1C2 and R1C10). can you please help with that or can you provide some sample code. Thanks.

Jawahar Jeevanandan J [Syncfusion]
Replied On November 28, 2011 06:27 AM

Hi Foram,

Sorry for the inconvenience. We can update only single cell at a time, it is not possible to update multiple cells by selecting the range of cells.

Please let us know if you have any queries.



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.