Round brackets not showing up correctly in RightToLeft flow direction in WPF
Flow direction in my WPF window is set to RightToLeft like so:
<TextBlock FlowDirection="RightToLeft" x:Name="test">
In code if I do test.Text = "(2/3)";
I see
(2/3)
But if I do test.Text = "asdf (2/3)";
I see
(asdf (2/3
What's going on here? Why is it that starting the text with a string changes the positioni开发者_JAVA技巧ng of the brackets?
I am not sure, but another more complex workaround is:
Friday, February 12, 2010 5:10 PM Ben Ronco - MSFT
Unfortunately this is a bug that we have recently discovered. You may be able to work around this issue by puttting some "invisible" non punctuation text at the end of your content like this:
{example modified}
<TextBlock FlowDirection="RightToLeft" x:Name="test">
<Run>Label1 (cms)</Run>
<Run FontSize=".01">i</Run>
</TextBlock>
Source: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3a723659-2bac-4d0c-80d8-09ba38e6cec1
When you have punctuation text at the end of the content try to use:
HorizontalContentAlignment="Right"
instead of:
FlowDirection="RightToLeft"
From: Vladvaly
October 20, 2010 6:39 AM
Source: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/3a723659-2bac-4d0c-80d8-09ba38e6cec1
I was having the same issue with related to StackPanel and Buttons.
Previous (not working way): NotWorkingScreenshot
Previous code:
<StackPanel Margin="2"
FlowDirection="RightToLeft"
Orientation="Horizontal">
<Button x:Name="buttonSaveFlipchart"
Width="100"
Margin="2"
Click="buttonSaveFlipchart_Click"
Content="{Binding Path=ButtonContentSave}"
IsEnabled="{Binding ButtonEnabledSaveFlipchart}" />
<Button x:Name="buttonEditFlipchart"
Margin="2"
Click="buttonEditFlipchart_Click"
Content="Muokkaa"
IsEnabled="{Binding ButtonEnabledEditFlipchart}" />
New (working way): WorkingScreenshot
New code:
<StackPanel Margin="2"
HorizontalAlignment="Right"
Orientation="Horizontal">
<Button x:Name="buttonEditFlipchart"
Margin="2"
Click="buttonEditFlipchart_Click"
Content="Muokkaa"
IsEnabled="{Binding ButtonEnabledEditFlipchart}" />
<Button x:Name="buttonSaveFlipchart"
Width="100"
Margin="2"
Click="buttonSaveFlipchart_Click"
Content="{Binding Path=ButtonContentSave}"
IsEnabled="{Binding ButtonEnabledSaveFlipchart}" />
So import were the changing of attribute FlowDirection to HorizontalAlignment.
精彩评论