wpf
wpf copied to clipboard
In an Arabic (ar) environment, TextBlock Run behaves abnormally when displaying pure numbers.
Description
In an Arabic (ar) environment, TextBlock Run behaves abnormally when displaying pure numbers.
Reproduction Steps
Create a new .NET 9 WPF application and add the following code:
public MainWindow()
{
CultureInfo.CurrentUICulture = new CultureInfo("ar");
this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentUICulture.Name);
this.FlowDirection = CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
InitializeComponent();
}
<Window
x:Class="WpfApp1.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"
Title="MainWindow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock FontSize="18" FontWeight="Bold">
<Run d:Text="25.4.10.10" Text="99.99.99.99" />
<LineBreak />
<Run d:Text="801" Text="801" />
<LineBreak />
<Run d:Text="802" Text="802" />
<LineBreak />
<Run d:Text="803" Text="803" />
<LineBreak />
</TextBlock>
</Grid>
</Window>
Expected behavior
Display numbers normally
Actual behavior
The displayed numbers are abnormal, like garbled text.
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response
Please clarify what you mean by normally and abnormally. I assume you are referring to the three squares between 99.
I cannot reproduce this.
What is your Windows build number?
Also try if adding this to your project file helps:
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Globalization.UseNls" Value="true" />
</ItemGroup>
Also try if adding this to your project file helps:
<ItemGroup> <RuntimeHostConfigurationOption Include="System.Globalization.UseNls" Value="true" /> </ItemGroup>
Even after adding this configuration, it is still the same as before.
Please clarify what you mean by normally and abnormally. I assume you are referring to the three squares between 99.
I cannot reproduce this.
What is your Windows build number?
Can you use the code I provided above to provide a screenshot of the running results?
I used your code, but you did not clarify what you consider normal and abnormal. Are you reporting that you see Arabic digits when you set the UI culture to Arabic? That is expected.
What is your Windows build number?