Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The symbols after “(“ in buttons behave differently in c sharp in wpf [zh-cn]

Tags:

c#

wpf

The symbols after ( in buttons behave differently.

I have 2 buttons in a dialog box namely, Save and Cancel.

I also have a name and value pair in a resource file, where the value for different languages are given.

In my problem, I have the ZH-CN (traditional Chinese) in my resource file.

If I give the data in my resource file as

SAVE 保存 (_S)

CANCEL 取消 (_C)

My output become

The closing bracket becomes reversed and comes to the beginning.

I tried increasing the size of the buttons as well, the output remains the same.

Code:

<Button Content="{x:Static resx:Resources.ShareCancel}"                                           
Name="CancelBtn" 
DataContext="{Binding}" 
Command="{Binding CancelCommand}"/>
        
<Button Content="{x:Static resx:Resources.ShareSave}"
Name="ShareBtn"
Command="{Binding ShareCommand, UpdateSourceTrigger=PropertyChanged}"/>
like image 546
Kaushik Velusamy Avatar asked Dec 05 '25 03:12

Kaushik Velusamy


1 Answers

The issue has to do with the flow direction property, which probably gets inherited from one of parent controls. People had encountered similliar problem and it seems like this is a bug:

  • Round brackets not showing up correctly in RightToLeft flow direction in WPF)
  • Weird rendering behavior in WPF for ToolTips with brackets or parentheses

The simplest solution is to set the FlowDirection in buttons

<Button Content="{x:Static resx:Resources.ShareCancel}"                                           
Name="CancelBtn" 
DataContext="{Binding}" 
Command="{Binding CancelCommand}"
FlowDirection="LeftToRight"/>

<Button Content="{x:Static resx:Resources.ShareSave}"
Name="ShareBtn"
Command="{Binding ShareCommand, UpdateSourceTrigger=PropertyChanged}"
FlowDirection="LeftToRight"/>
like image 132
netaholic Avatar answered Dec 07 '25 22:12

netaholic