Question

I am creating a User control which has a canvas and within which I have a Textblock. I need to enter hebrew text so I set the FlowDirection of canvas to RightToLeft but when I change flow direction to RightToLeft The text is not getting displayed. The XAML and snapshot is as below, why is it happening?

 <Canvas x:Name="canvas" 
               FlowDirection="RightToLeft"
                >


            <TextBlock x:Name="textBlock1"
                       Height="{Binding Height}" 
                       FontSize="50"
                       TextWrapping="NoWrap" 
                       Foreground="{Binding Foreground}"
                       Text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"     
                       />
        </Canvas>

Snapshot when Flowdirection of canvas is RightToLeft

enter image description here

Snapshot when Flowdirection of canvas is LeftToRight

enter image description here

Was it helpful?

Solution

Set Horizontal Alignment of TextBlock to Left and width of the textblock

              <TextBlock x:Name="textBlock1"
               Height="46" 
               FontSize="50"
               HorizontalAlignment="Left"
              FlowDirection="RightToLeft"
               TextWrapping="NoWrap" 
               Foreground="White"
               Text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" Width="434"
               />     

OTHER TIPS

This would help you:

<Canvas x:Name="canvas" 
           FlowDirection="RightToLeft"
           >
           <TextBlock x:Name="textBlock1"
           Height="46" 
           FontSize="50"                           
           TextWrapping="NoWrap" 
           Foreground="White"
           Text="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"  Width="456"
           />
        </Canvas>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top