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 6538465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:44:20+00:00 2026-05-25T10:44:20+00:00

Sometimes when I use a textbox it is not possible to scroll all the

  • 0

Sometimes when I use a textbox it is not possible to scroll all the way down to see the last words.

I’ve included an example with three textboxes with identical content, but different widths. The one to the left does not show all words.

Move to the end of a textbox by selecting it and then press ‘ctrl’+’end’. When I do this for the textbox to the left (‘_tb1’), I cannot see the cursor and I cannot see the last words. It seems as the cursor and words are ‘below’ the textbox. I can though mark and copy the text that is not shown. The last word should be “si+”, see code below. I’ve verified that the ‘Text’ property of the textbox contains all text.

This has so far only happened when I use ‘TextWrapping=”Wrap”‘ and for certain widths.

Any suggestions on how to fix it?

Textbox to the left does not show last words

<UserControl x:Class="Silverlight4TextBoxProblem.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid Width="500" Height="150">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBox Name="_tb1" Grid.Column="0" TextWrapping="Wrap" 
                 FontFamily="Arial" FontSize="12"
                 VerticalScrollBarVisibility="Visible"
                 Width="100"/>
        <TextBox Name="_tb2" Grid.Column="1" TextWrapping="Wrap" 
                 FontFamily="Arial" FontSize="12" 
                 VerticalScrollBarVisibility="Visible"
                 Width="75"/>
        <TextBox Name="_tb3" Grid.Column="2" TextWrapping="Wrap" 
                 FontFamily="Arial" FontSize="12"
                 VerticalScrollBarVisibility="Visible"
                 Width="150"/>
        <Button Grid.Column="3" Click="ButtonClick" Content="Assert _tb1"/>
    </Grid>
</UserControl>

Code-behind

public partial class MainPage : UserControl
{
    private readonly string ErrorText = @"Lorem ipsum dolor sit amet+++," + Environment.NewLine 
        + "consectetur adipisicing elit, sed do eiusmod" + Environment.NewLine
        + "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam," + Environment.NewLine
        + "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo" + Environment.NewLine
        + "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse" + Environment.NewLine
        + "cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non" + Environment.NewLine
        + "proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem" + Environment.NewLine
        + "ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor" + Environment.NewLine
        + "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis" + Environment.NewLine
        + "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." + Environment.NewLine
        + "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu" + Environment.NewLine
        + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in" + Environment.NewLine
        + "culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit" + Environment.NewLine
        + "amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore" + Environment.NewLine
        + "et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation" + Environment.NewLine
        + "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor" + Environment.NewLine
        + "in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla" + Environment.NewLine
        + "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui" + Environment.NewLine
        + "officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet," + Environment.NewLine
        + "consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et" + Environment.NewLine
        + "dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco" + Environment.NewLine
        + "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in" + Environment.NewLine
        + "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." + Environment.NewLine
        + "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia" + Environment.NewLine
        + "deserunt mollit anim id est laborum. Lorem ipsum dolor si+";

    public MainPage()
    {
        InitializeComponent();

        _tb1.Text = ErrorText;
        _tb2.Text = ErrorText;
        _tb3.Text = ErrorText;
    }

    private void ButtonClick(object sender, RoutedEventArgs e)
    {
        MessageBox.Show(_tb1.Text.Last().ToString());
    }
}
  • 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-25T10:44:21+00:00Added an answer on May 25, 2026 at 10:44 am

    So I´ve had the exact same propblem. Depending on you requirements this can be solved by using a RichTextBox instead. And as a bonus it appears as if you get faster scrolling.

    However, a RTB doesn´t have a text property or a max length property to bind to. I solved this by inheriting a RTB to my CustomTextBox.

    If you hook up to the event contentchanged

    public class CustomTextBox : RichTextBox
    {
        public CustomTextBox()
        {
            ContentChanged += HandleContentChanged;
        }
    ...
    

    and then

    private void HandleContentChanged(object sender, ContentChangedEventArgs e)
    {
        var text = GetContent(out blocks);
        Text = text;
    }
    

    and add the TextProperty to bind to

    public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(CustomTextBox), new PropertyMetadata(string.Empty, HandleTextChanged));
    
        private static void HandleTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var customTextBox = (CustomTextBox)d;
    
            var newValue = (string)e.NewValue;
    
            //This method is only run when set from codebehind
            UpdateOnTextChange(customTextBox, newValue);
        }
    
        private static void UpdateOnTextChange(CustomTextBox customTextBox, string newValue)
        {
            int blocks;
    
            if (customTextBox.GetContent(out blocks) != newValue)
            {
                var binding = customTextBox.GetBindingExpression(TextProperty);
    
                customTextBox.Blocks.Clear();
                var value = EnsureString(newValue);
                customTextBox.Selection.Text = value;
    
                if (customTextBox.HasTextChanges)
                {
                    customTextBox.HasTextChanges = false;
                    //reset binding... 
                    if (binding != null)
                    {
                        customTextBox.SetBinding(TextProperty, binding.ParentBinding);
                    }
                }
    
                var bindingExpression = customTextBox.GetBindingExpression(TextProperty);
    
                if (bindingExpression != null)
                    bindingExpression.UpdateSource();
            }
        }
    

    And since you will want to be able to get the content of the CustomTextBox as a string:

        public string GetContent(out int blocks)
        {
            var builder = new StringBuilder();
            blocks = 0;
            foreach (var run in Blocks.OfType<Paragraph>().Select(paragraph => paragraph.Inlines.FirstOrDefault()).OfType<Run>())
            {
                blocks++;
                builder.Append(run.Text);
                builder.Append(Environment.NewLine);
            }
            var content = builder.ToString();
            if (content.EndsWith(Environment.NewLine, StringComparison.CurrentCulture))
                content = content.Substring(0, content.Length - 2);
            return content ?? string.Empty;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I see people use http://codepad.org as a way to quickly run/test their Perl
sometimes i use debug code to alert something in javascript (for example, matching something
Below is a rather frightening pattern I sometimes use as a lazy way to
I sometimes use the feature 'Reconcile Offline Work...' found in Perforce's P4V IDE to
I mostly use lambda functions but sometimes use nested functions that seem to provide
TCP and UDP(sometimes) use a simple checksum to make sure the contents are correct.
I normally use gVim for editing, but I sometimes use vim when remotely connecting
I use Emacs primarily for coding Python but sometimes I use IDLE. Is there
In a Rails app sometimes you use a redirect in an action... redirect_to :controller
I sometimes need to use Visual Studio when I have limited screen real estate

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.