How to retain cursive style in TextBlock with Inlines?

Emon Haque 3,176 Reputation points
2021-08-13T04:31:18.853+00:00

This is what I've in MainWindow.xaml:

<Grid>  
    <Grid.Resources>  
        <Style TargetType="TextBlock">  
            <Setter Property="FlowDirection" Value="RightToLeft"/>  
            <Setter Property="FontSize" Value="60"/>  
            <Setter Property="FontFamily" Value="Amiri"/>  
            <Setter Property="HorizontalAlignment" Value="Center"/>  
            <Setter Property="VerticalAlignment" Value="Center"/>  
        </Style>  
    </Grid.Resources>  
    <Grid.RowDefinitions>  
        <RowDefinition/>  
        <RowDefinition/>  
        <RowDefinition/>  
        <RowDefinition/>  
    </Grid.RowDefinitions>  
    <TextBlock FontFamily="Arial" Text="bialGuyb"/>  
    <TextBlock Grid.Row="1" Text="بِالغَيب"/>  
    <TextBlock Grid.Row="2"   
               Typography.StandardLigatures="True">  
        <Run Text="بِ"/>  
        <Run Text="الغَيب"/>  
    </TextBlock>  
    <TextBlock Grid.Row="3"  
               Typography.DiscretionaryLigatures="True">  
        <Run Text="بِ"/>  
        <Run Text="ال"/>  
        <Run Text="غَيب"/>  
    </TextBlock>  
</Grid>  

and it produces this:

122898-capture.png

so when I type bialGuyb in Text property of the TextBlock with arabic phonetic keyboard on, I get the drawing in second row and that is the correct and expected format. When I separate bi from alGuyb, as in third row, or bi as well as al from Guyb, as in fourth row, it doesn't work although I don't have any leading or trailing spaces in any of those Run.

How to get the correct format?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,674 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 38,256 Reputation points Microsoft Vendor
    2021-08-13T09:29:19.157+00:00

    You could try to use only one Run as a line to avoid CR LF issues between </Run> and the next <Run> element. Also here is reference you can refer to.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful