Single Click Editing problem

Nov 6, 2008 at 5:33 PM
Hi,
I tried out the approach of tips and tricks but it does not work correctly.

The exception is:
{System.InvalidOperationException: Cannot change cell selection when the SelectionUnit is FullRow.

I'd like to use FullRow Selection. Is there another approach.


The other problem is, that I'm getting another color for the selected row or selected cell respectively when I have this.

Code behind:

dgc = new DataGridCheckBoxColumn (); 
dgc.Header =
this.m_strTranslate_CheckStorage; 
Style checkBoxCellStyle = (Style)this.FindResource ("SingleClickEditing"); 
dgc.CellStyle = checkBoxCellStyle;
dgbc = (
DataGridBoundColumn)dgc; 
b =
new Binding ("check_storage");
b.Mode =
BindingMode.TwoWay;
dgbc.Binding = b;
dg.Columns.Add (dgc);


XAML:
<Style x:Key="SingleClickEditing" TargetType="{x:Type dg:DataGridCell}" >

<EventSetter Event="PreviewMouseLeftButtonDown" Handler="DataGridCell_PreviewMouseLeftButtonDown"></EventSetter>

<Setter Property="MinHeight" Value="20" />

<Setter Property="HorizontalAlignment" Value="Stretch" />  

 

<Style.Triggers>

 <Trigger Property="IsSelected" Value="true">

 

<Setter Property="Background" Value="LightSeaGreen"/>

 

</Trigger>

 

<MultiTrigger>

 

<MultiTrigger.Conditions>

 

<Condition Property="IsMouseOver" Value="true" />

 

<Condition Property="IsSelected" Value="false" />

 

</MultiTrigger.Conditions>

 

<Setter Property="Background" Value="LightBlue" />

 

</MultiTrigger>

 

</Style.Triggers>

 

</Style 

XAML:

 

Many zhanks in advanced.

 WorstCase.

Coordinator
Nov 7, 2008 at 3:34 PM
Hi WorstCase,

We updated the Single Click Editing How-To yesterday so that it will handle the FullRow case.  Let us know if you have any questions.

Thanks!
Samantha
Nov 10, 2008 at 5:37 PM
Thank you Samantha.
I'm using also the SelectionChanged event.
When using the event handlers together, then the SelectionChanged event fires twice. First time for the row that losses the focus and second for the new row I want to select.

So I guess the best way is to use the RowClick event instead.
Is there a RowClick event  available?

Many thanks in advanced. 
WorstCase.