I think there is a problem with WPF and right to left input when it comes to handling the percent sign (might also apply to similar signs).
When the TextBox is Right-to-Left oriented and there is no Hebrew characters at the start of the text, the percent sign is rendered on the wrong side of the number.
You can see the abnormal behaviour in this video:
Here is my application XAML (As you can see there is nothing in it):
<Window x:Class="HebrewTextTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow">
<Grid FlowDirection="RightToLeft" Margin="10">
<TextBox Text=" 25% הנחה"/>
</Grid>
</Window>
Any idea if there is a solution for this?
Note that I do not have any control on the text, since the user types it in...
On textbox text changed event add the right to left mark to the text:
<TextBox Name="textBox1" Text=" 25% הנחה" TextChanged="Textbox1_TextChanged"/>
bool addRtlMark = false;
private void Textbox1_TextChanged(object sender, TextChangedEventArgs e)
{
if (!addRtlMark)
{
addRtlMark = true;
textBox1.Text = "\u200f" + textBox1.Text.Replace("\u200f", "");
addRtlMark = false;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With