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

  • Question

  • Hi,

    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. 

    LeftToRight:

    
    RightToLeft:

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

    XAML:

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

    C#:

     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.

    • Moved by CoolDadTx Monday, April 20, 2020 1:59 PM WPF related
    Monday, April 20, 2020 10:32 AM

All replies

  • This forum is for C#-specific questions only. Please post questions related to the WPF framework in the new Microsoft Q&A forum.

    Michael Taylor http://www.michaeltaylorp3.net

    Monday, April 20, 2020 1:59 PM