This project has moved and is read-only. For the latest updates, please go here.

IntegerUpDown In DataGrid.CellEditTemplate Can not selectAll

Apr 15, 2014 at 4:14 AM
Edited Apr 15, 2014 at 4:17 AM
<DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <Grid Background="AliceBlue" FocusManager.FocusedElement="{Binding ElementName=intUpDown}">
                                <xwt:IntegerUpDown Value="{Binding Age}" Name="intUpDown" SelectAllOnGotFocus="True" GotFocus="intUpDown_GotFocus">
                                </xwt:IntegerUpDown>
                            </Grid>
                        </DataTemplate>
 </DataGridTemplateColumn.CellEditingTemplate>
Hi:
I tried set 'SelectAllOnGotFocus' true and 'AutoSelectBehavior' OnFocus, but it doesn't work.
Is there any method which I can use to select all programmatically?
Do you have any idea?
Thanks in advance.
Developer
Apr 15, 2014 at 4:42 PM
Hi,

"SelectAllOnGotFocus'" is obsolete, you can forget it and only set "AutoSelectBehavior" to "OnFocus".

If used as an independent control, the IntegerUpDown.AutoSelectBehavior will work.

To use it in a DataGridTemplateColumn.CellEditingTemplate, try using a trigger :
<DataTemplate x:Key="MyDataTemplate">
         <Grid Background="AliceBlue">
            <xctk:IntegerUpDown Value="{Binding Age}"
                               Name="intUpDown"
                               AutoSelectBehavior="OnFocus"/>
         </Grid>

         <DataTemplate.Triggers>
            <Trigger SourceName="intUpDown"
                     Property="IsVisible"
                     Value="True">
               <Setter TargetName="intUpDown"
                       Property="FocusManager.FocusedElement"
                       Value="{Binding ElementName=intUpDown}" />
            </Trigger>
         </DataTemplate.Triggers>
      </DataTemplate>
Marked as answer by foman on 4/16/2014 at 2:13 AM