How do I get RTL text in FlowDocument right-aligned?

Hello,

I have a FlowDocument with some figure and table and paragraphs in it. I use it usually to display LTR text and that's okay. However, If I want to display Hebrew for example, the paragraphs are still left aligned.

Is there a way how to get it aligned properly? Unfortunately I don't have CultureInfo information about the text, just the text; but I'd like it to be aligned automatically anyway, if possible.

Any ideas welcomed,

thanks, Jan.

[524 byte] By [JanKu?era] at [2008-1-9]
# 1
Hello,

I think they are not so smart to identify the direction of the contained text! You should set the direction or alignment your self.
may be you can make a conditional statement based on some characters of hebrew language and then set the flowdirection or alignment.

Parham.

Parham! at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Hi,

thank you for reply. Hmm, that's what I was afraid of. So..not quite a WPF question, but any way, how to detect if text is RTL without checking for specific set of languages? Like Char.IsRtl or something like that....

Jan

JanKu?era at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 3

Hello, are you sure? Actually when you set FlowDirection to RightToLeft, and set TextAlignment to Left (the default value), the result will appear to be right aligned. This should be done automatically, and is the result I got. Maybe you’ve manually set TextAlignment to Right? If so, in a RightToLeft environment, your text will appear to be left aligned.

Yi-LunLuo-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 4

Hi.

Well first this is the very unfortunate confusion caused be using Left and Right names instead of good old Near and Far, as I pointed at Near, Far, Left, Right (WPF) and NearToFar, FarToNear, LeftToRight, RightToLeft (WPF) feedback at Connect (two months ago, still without any answer!).

And concerning my problem. I agree that with setting the FlowDirection to RightToLeft, the left-aligned paragraphs become right-aligned. However, this is not what I'm asking for. Originally I didn't want to set FlowDirection at all, expecting the paragraphs to get their defaults based on the content. Well I may or might not agree whether this would be good behaviour, it seems it simply does not work this way.

So I decided I will manually set the FlowDirection to RightToLeft to get the effect. But how should I detect, if the text is naturally RTL? I can get the character and test whether it is Arabic, Hebrew and so on, but I'll likely miss some case, so I'm looking for more general way of doing that.

Jan

JanKu?era at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 5
the general way would be checking out the language property... however this would work only in the case of typing where the lang tags are added... if its a copy paste from word/ other apps the tags do not get copied.. so here you would have to fallback on the character detection as you previously mentioned
LesterLobo-MSFT at 2007-10-3 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified