WPF : Cursor not visible in text box first position in RightToLeft flow direction

Muneesh Kumar 1 Reputation point


I have tried to remove all margin value in TextBox by accessing inner element and set Margin as 0. With this value cursor not visible in RightToLeft direction first place. But working fine in LeftToRight direction.





You can see the cursor in LeftToRight direction-> First place. But the cursor not showing in RightToLeft direction first place.


<StackPanel Margin="5">  
        <ContentControl Margin="10">  
            <TextBox Text="0.00" Loaded="TextBox_Loaded" />  
        <ContentControl Margin="10" FlowDirection="RightToLeft">  
            <TextBox Text="0.00" Loaded="TextBox_Loaded"/>  


 private void TextBox_Loaded(object sender, RoutedEventArgs e)  
            var frameworkElement = sender as FrameworkElement;  
            var container = VisualTreeHelper.GetChild(frameworkElement, 0) as FrameworkElement;  
            var contentElement = container.FindName("PART_ContentHost") as ScrollViewer;  

            if (contentElement != null && contentElement.Content is FrameworkElement)  
                var textBoxView = contentElement.Content as FrameworkElement;  
                textBoxView.Margin = new Thickness(0, 0, 0, 0);  

Thanks, Muneesh.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,700 questions
{count} votes