Single Click Editing on Custom Textbox Column

Feb 17, 2009 at 9:41 PM
Hi

I tried the Single-Click editing tip on a custom textbox column but it seems not to work. The event is called ok, but 
the textbox  needs one click to focus and select the cell and one click to put the textbox in to editing mode.
Is there any way to have the textbox in editing mode with the first click?

Below a short  my sample code

Many Thanks

<

Window x:Class="oneclick.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"

Title="Window1" Height="300" Width="300"

Loaded="Window_Loaded">

 <Window.Resources>

 

 

 

<Style x:Key="CellStyle" TargetType="{x:Type toolkit:DataGridCell}">

 

 

 

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

 

 

 

</Style>

</Window.Resources>

<Grid 

<toolkit:DataGrid

x:Name="ProjectDataGrid" AutoGenerateColumns="False"  

 

 

EnableRowVirtualization="True"

 

 

 

SelectionUnit="CellOrRowHeader"

 

 

 It

emsSource="{Binding Path=MyList}"

 

 

 

>

 

 

 

<toolkit:DataGrid.Columns>

 

 

 

<toolkit:DataGridTemplateColumn

 

 

 

CellStyle ="{StaticResource CellStyle}"

 

 

 

Header="Field1"

 

 

 

>

 

 

 

<toolkit:DataGridTemplateColumn.CellTemplate>

 

 

 

<DataTemplate>

 

 

 <T

extBlock

 

 

 

Text="{Binding Path=Field1}"

 

 

 

/>

 

 

 

</DataTemplate>

 

 

 

</toolkit:DataGridTemplateColumn.CellTemplate>

 

 

 

<toolkit:DataGridTemplateColumn.CellEditingTemplate>

 

 

 

<DataTemplate>

 

 

 

<TextBox

 

 

 

Text="{Binding Path=Field1}"

 

 

 

</TextBox>

 

 

 

</DataTemplate>

 

 

 

</toolkit:DataGridTemplateColumn.CellEditingTemplate>

 

 

 

</toolkit:DataGridTemplateColumn>

 

 

 

</toolkit:DataGrid.Columns>

 

 

 

</toolkit:DataGrid>

 

 

 </Gr

id>

 

 

 </

Window>