locked
Can`t programmatically select text in textbox in this code-begind RRS feed

  • Question

  • MainPage.xaml:

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid>
                    <Button Content="Button"/>
                </Grid>

                <Grid Grid.Row="1">
                    <TextBox x:Name="textBox"
                             Text = "Hello World">
                    </TextBox>
                </Grid>
            </Grid>
    </Grid>

    MainPage.xaml.cs:

    public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
                this.textBox.SelectAll();
            }
        }




    • Edited by Anton Em Friday, April 10, 2015 12:00 PM
    Friday, April 10, 2015 10:10 AM

Answers

  • I found reason. The problem is that textBox is unfocused, when there is this button )


    • Marked as answer by Anton Em Friday, April 10, 2015 12:22 PM
    Friday, April 10, 2015 12:22 PM