Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8397713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:51:59+00:00 2026-06-09T20:51:59+00:00

This seems a simple question but I was not able to find the answer

  • 0

This seems a simple question but I was not able to find the answer in the web. The only thing I want consists in to get the content hightlighted in the textbox, when the user gets in (‘Price’ or ‘Quantity’ in this example). Right now it’s necessary double click first in order to edit the content.
The content should be selected automatically when it get’s focus.
How can I do this?

Thank you

<Window x:Class="Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Window1" Height="350" Width="479" Name="Window1">
<Window.Resources>
    <CollectionViewSource x:Key="MasterView" />
    <CollectionViewSource Source="{Binding Source={StaticResource MasterView}, Path='OrderDetails'}" x:Key="DetailView" />
    <CollectionViewSource x:Key="CustomerLookup" />
    <CollectionViewSource x:Key="ProductLookup" />
</Window.Resources>
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="42" />
        <RowDefinition Height="110" />
        <RowDefinition Height="42" />
        <RowDefinition Height="147*" />
    </Grid.RowDefinitions>
    <Grid Grid.Row="1" Name="Grid1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="146*" />
            <ColumnDefinition Width="346*" />
        </Grid.ColumnDefinitions>
        <StackPanel Name="StackPanel1" >
            <Label Height="28" Name="Label1" Width="Auto" HorizontalContentAlignment="Right">ID:</Label>
            <Label Height="28" Name="Label2" Width="Auto" HorizontalContentAlignment="Right">Customer:</Label>
            <Label Height="28" Name="Label3" Width="Auto" HorizontalContentAlignment="Right">Order Date:</Label>
            <Label Height="28" Name="Label4" Width="Auto" HorizontalContentAlignment="Right">Ship Date:</Label>
        </StackPanel>
        <StackPanel Name="StackPanel2" Grid.Column="1" DataContext="{Binding Source={StaticResource MasterView}}">
            <TextBox Height="23" Name="TextBox1" Width="100" Margin="2" HorizontalAlignment="Left" IsReadOnly="True" 
                     Text="{Binding Path=OrderID, Mode=OneWay}"/>

            <ComboBox Height="23" Name="ComboBox1" Width="177" Margin="2"  HorizontalAlignment="Left" 
                      IsEditable="False"
                      ItemsSource="{Binding Source={StaticResource CustomerLookup}}"
                      SelectedValue="{Binding Path=CustomerID}" 
                      SelectedValuePath="CustomerID" 
                      DisplayMemberPath="Name"/>

            <TextBox Height="23" Name="TextBox3" Width="100" Margin="2" HorizontalAlignment="Left" 
                     Text="{Binding Path=OrderDate}"/>
            <TextBox Height="23" Name="TextBox4" Width="100" Margin="2" HorizontalAlignment="Left" 
                     Text="{Binding Path=ShipDate}"/>

        </StackPanel>
    </Grid>
    <StackPanel Name="StackPanel3" Orientation="Horizontal">
        <Button Height="25" Name="btnAdd" Width="Auto" Margin="3">Add Order</Button>
        <Button Height="25" Name="btnDelete" Width="Auto" Margin="3">Delete Order</Button>
        <Button Height="25" Name="btnPrevious" Width="75" Margin="3">Previous</Button>
        <Button Height="25" Name="btnNext" Width="75" Margin="3">Next</Button>
        <Button Height="25" Name="btnSave" Width="75" Margin="3">Save</Button>
    </StackPanel>
    <StackPanel Name="StackPanel4" Orientation="Horizontal" Grid.Row="2">
        <Button Height="25" Name="btnAddDetail" Width="Auto" Margin="3">Add Detail</Button>
        <Button Height="25" Name="btnDeleteDetail" Width="Auto" Margin="3">Delete Detail</Button>
    </StackPanel>
    <ListView Grid.Row="3" Name="ListView1" 
              IsSynchronizedWithCurrentItem="True"
              ItemsSource="{Binding Source={StaticResource DetailView}}">
        <ListView.ItemContainerStyle>
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <EventSetter Event="GotFocus" Handler="Item_GotFocus" />
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.View>
            <GridView>
                <GridViewColumn Header="ID" Width="75">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Path=OrderDetailID}" 
                                     Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="OrderID" Width="75">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Label Content="{Binding Path=OrderID}" 
                                     Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Product" Width="150">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox IsEditable="False" 
                              Name="cboProduct"
                              IsSynchronizedWithCurrentItem="False"       
                              ItemsSource="{Binding Source={StaticResource ProductLookup}}"
                              SelectedValue="{Binding Path=ProductID}" 
                              DisplayMemberPath="Name" 
                              SelectedValuePath="ProductID" 
                              Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Quantity" Width="75">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Path=Quantity}" 
                                     Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
                <GridViewColumn Header="Price" Width="75">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox Text="{Binding Path=Price}" 
                                     Margin="-6,0,-6,0"/>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>
   </Grid>
</Window>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:52:01+00:00Added an answer on June 9, 2026 at 8:52 pm

    You have to use the TextBox.SelectAll property. You can manually wire it up on a per-textbox or per-window basis, or you can do it more globally. this article describes one method for doing it globally, and this answer describes another.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like a simple question, but I haven't been able to find the
this seems like a simple enough question but I can't seem to find a
This seems like a simple question, but has proven to be difficult to find
This is a simple question really (but I couldn't seem to find the answer
This might be a very simple thing in jquery but I am not able
this is a simple question, but one that I have not been able to
This seems like a simple question, but it is difficult to search for. I
This seems to be an embarrassingly simple question, but, after a day of reading
This is a very simple question, but I can't seem to find something about
This seems to me like a very simple question, but I can't seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.