question

MojtabaHakim-8125 avatar image
0 Votes"
MojtabaHakim-8125 asked MojtabaHakim-8125 commented

Why Caret is hidden when FlowDirection is RightToLeft On Material Design in C# WPF?

I'm using C# WPF with http://materialdesigninxaml.net/ (MaterialDesign),

The Problem :

For MaterialDesignOutlinedTextBox Style, the caret index in TextBox is Visible when FlowDirection is set to LeftToRight and is focused :
enter image description here

but when I change that to RightToLeft the caret index in hidden event it's focused ! : enter image description here
even in typing still is hidden : 260414-image.png

It doesn't show until I click on the text box again, and the interesting thing is that if the text box is empty, the Caret Index is slightly out of the frame and a little unclear.

260388-image.png
XAML:

 <Window x:Class="WpfApp3.MainWindow"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:WpfApp3"
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         mc:Ignorable="d"
         Title="MainWindow" Height="450" Width="800" WindowStartupLocation="CenterScreen" >
     <Grid>
         <TextBox    Style="{StaticResource MaterialDesignOutlinedTextBox}"
                     TextWrapping="Wrap"
                     FlowDirection="RightToLeft"
                     Text="Righ To Left"
                     IsEnabled="{Binding Path=IsChecked, ElementName=MaterialDesignOutlinedTextBoxEnabledComboBox}" Margin="101,32,235,0" Height="54" VerticalAlignment="Top" Padding="0" />
         <Label Content="Caret Index for Righ to Left :" FlowDirection="RightToLeft" HorizontalAlignment="Left" Margin="582,45,0,0" VerticalAlignment="Top" Height="37" FontSize="15" Width="198"/>
         <TextBox   
             TextWrapping="Wrap"
             Text="Left"
             CaretIndex="2"
             IsEnabled="{Binding IsChecked, ElementName=MaterialDesignOutlinedTextBoxEnabledComboBox}" Margin="246,147,90,0" Height="54" VerticalAlignment="Top" FlowDirection="RightToLeft">
             <TextBox.Style>
                 <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignOutlinedTextBox}">
                     <Setter Property="CaretBrush">
                         <Setter.Value>
                             <SolidColorBrush Color="Blue"/>
                         </Setter.Value>
                     </Setter>
                 </Style>
             </TextBox.Style>
         </TextBox>
         <Label Content="Caret Index for Left to Righ :" HorizontalAlignment="Left" Margin="22,156,0,0" VerticalAlignment="Top" Height="37" FontSize="15" Width="198"/>
     </Grid>
 </Window>

Very important point :
This problem does not exist in this 3.2.0 version

Same issues here :

insertion-point-hides-at-the-start-of-line-while-using-right-to-left-flow-direct

wpf-cursor-not-visible-in-text-box-first-position.html


dotnet-csharpwindows-wpfdotnet-wpf-xaml
image.png (2.2 KiB)
image.png (3.9 KiB)
image.png (7.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, @MojtabaHakim-8125. Based on my tests, I reproduced your problem. The native TextBox cursor blinks fine. It is recommended that you ask questions on GitHub.260847-4.gif


0 Votes 0 ·
4.gif (80.7 KiB)

follow these steps:

1- Clear RighToLeft Text

2- Focus another Control

3- Focus On RighToLeft Control (TextBox)

and look the caret

please download my source code

0 Votes 0 ·

0 Answers