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

  • SEARCH
  • Home
  • 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 830967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:07:45+00:00 2026-05-15T04:07:45+00:00

I have a custom control template which is set via the style property on

  • 0

I have a custom control template which is set via the style property on a TextBox. The visual poperties are set correctly, even typing to the textbox works, but there is no insertion cursor (the | symbol) visible which makes editing challenging for our users.

How does the control template need changing to get the traditional TextBox behavior back?

<Style x:Key="DemandEditStyle" TargetType="TextBox">
    <EventSetter Event="LostFocus" Handler="DemandLostFocus" />
    <Setter Property="HorizontalAlignment" Value="Stretch" />
    <Setter Property="VerticalAlignment" Value="Stretch" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="1" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="1" />
                    </Grid.RowDefinitions>
                    <Grid.Background>
                        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                            <GradientStop Color="White" Offset="0" />
                            <GradientStop Color="White" Offset="0.15" />
                            <GradientStop Color="#EEE" Offset="1" />
                        </LinearGradientBrush>
                    </Grid.Background>
                    <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Background="Black" />
                    <Border Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Background="Black" />
                    <Grid Grid.Row="0" Grid.Column="0" Margin="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="1" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="1" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="1" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Background="Black" />
                        <Border Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" Background="Black" />
                        <Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" Background="#CCC" />
                        <Border Grid.Row="0" Grid.Column="2" Grid.RowSpan="3" Background="#CCC" />
                        <TextBlock Grid.Row="1" Grid.Column="1"
                               TextAlignment="Right" HorizontalAlignment="Center" VerticalAlignment="Center" 
                               Padding="3 0 3 0" Background="Yellow"
                               Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text}"
                               Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}, AncestorLevel=1}, Path=ActualWidth}" />
                    </Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Update: Replacing the inner-most TextBox with a ScrollViewer and naming it PART_ContentHost indeed shows the text insertion cursor.

  • 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-05-15T04:07:46+00:00Added an answer on May 15, 2026 at 4:07 am

    I suppose the reason is that your template lacks an element called PART_ContentElement. As stated here, an element with that name is used to display the content of the TextBox. However, in the v3.5 version of this document, the element is called PART_ContentHost and is further restricted to be a ScrollViewer or an AdornerDecorator.

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

Sidebar

Related Questions

I have a custom control that exposes a property. When I set it using
I have a custom control which includes a property of the following definition: [PersistenceMode(PersistenceMode.InnerProperty)]
I have a custom server control with a property of Title. When using the
I have a custom user control with a textbox on it and I'd like
I have a custom control which contains a Repeater control. The Repeater has an
Here's the situation: I have a custom TextBox control that contains multiple other TextBox
I have a set of custom ASP.NET server controls, most of which derive from
I have created a custom style for my WPF datagrid by overriding its control
If I have a custom user control (say, MyCustomControl.ascx) which contains a number of
I have a custom user control UserProfileLink on which I have two basic string

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.