Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two TextBox in a cell of DataGrid in silverlight,when the cell put into edit mode ,both of them highlight,but i just want one.For example,when i click button1 ,the first TextBox highlight.I click button2 another hightlight.How to do it?This is my code
XML
<my:DataGridTemplateColumn.CellEditingTemplate>
                                        <DataTemplate>
                                            <Grid x:Name="Root">
                                                <Grid>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="25" />
                                                        <RowDefinition Height="1" />
                                                        <RowDefinition Height="25" />
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="120"/>
                                                    </Grid.ColumnDefinitions>
                                                    <!-- Row 0 -->
                                                    <TextBox Background="#FFCCFAFB" Text="{Binding StartNO,Mode=TwoWay}"/>
                                                    <!-- Row 1 -->
                                                    <Line Stroke="#FF8CB2C6" X1="1" X2="84" Y1="1" StrokeDashArray="2" Grid.Row="1" Y2="1" />
                                                    <!--<Rectangle Fill="#FFC9CACA" VerticalAlignment="Stretch" Height="1" Visibility="Visible" Grid.Row="1"/>-->
                                                    <!-- Row 2 -->
                                                    <TextBox Background="#FFCCFAFB" Text="{Binding EndNO,Mode=TwoWay}" Grid.Row="2"/>
                                                </Grid>
                                            </Grid>
                                        </DataTemplate>
                                    </my:DataGridTemplateColumn.CellEditingTemplate>
Posted

1 solution

Hi,

When clicking the button call the .Focus() & .SelectAll() to the textbox level.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900