WPF : Cursor not visible in text box first position in RightToLeft flow direction
Muneesh Kumar
1
Reputation point
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.
Sign in to answer