Round brackets not showing up correctly in RightToLeft flow direction in WPF

假装没事ソ 提交于 2019-12-11 03:59:59

问题


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 positioning of the brackets?


回答1:


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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/4835920/round-brackets-not-showing-up-correctly-in-righttoleft-flow-direction-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!