开发者

WPF: how does FlowDirection.RightToLeft change a string?

I have a FormattedText item. I have the flowdirection set to RightToLeft, and I am not sure how it works. It changes my strings really inconsistantly.

I imagined that it would just take a string, and display it backwards (either by characters, or by words), but in testing it does wierd things.

开发者_StackOverflow社区==================================================

examples,

the string "90%", is displayed as "%90"

Why does the % sign go from the end to the start?

the string "12 34 56 this is my (string)" 
is displayed as "(this is my (string 56 34 12"

why do the numbers go to the end, and one bracket goes to the beginning and switched direction?

the string "this is a string"
is displayed as "this is a string"

why does nothing happen in this case??

==================================================

my formattedText looks like this:

FormattedText sectionNum = new FormattedText(
   sectNum,
   CultureInfo.CurrentCulture,
   FlowDirection.RightToLeft,
   new Typeface("Verdana"),
   14,
   Brushes.Black);
context.DrawText(sectionNum, new Point(790 - 96, 20));

Anyone know what is going on? I need to be able to display each string so that it reads the same as LeftToRight, when set to RightToLeft.

Thanks!


TextInfo has own FlowDirection and it overrides WPF FlowDirection.

So if you type in arabic or hebrew it will automatically use "Right to left" direction. But there is a problem if you use signs ";", " "(space). Compilor thinks as it can be in both directions and can it put as "Left to right" in arabic, so here your should use custom Wpf FlowDirection.

In your examples compilor knows about english letters and use "Left to right" direction, but goes crazy with spaces and numbers.

Here is similar question with link to good part in the book.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜