2016-12-17 2 views

Répondre

1

Mais le retour LeftToRight toujours, même pour le droit aux paragraphes gauche

Non, elle ne précise pas l'exemple suivant démontre:

<RichTextBox x:Name="rtb"> 
     <FlowDocument> 
      <Paragraph FlowDirection="RightToLeft"> 
       <TextBlock>right to left...</TextBlock> 
      </Paragraph> 
      <Paragraph FlowDirection="LeftToRight"> 
       <TextBlock>right to left...</TextBlock> 
      </Paragraph> 
     </FlowDocument> 
    </RichTextBox> 

    <CheckBox x:Name="rtlBtn" /> 
    <Button Content="Click" Click="Button_Click" /> 

private void Button_Click(object sender, RoutedEventArgs e) 
    { 
     var textRange = rtb.Selection; 
     if(textRange != null) 
     { 
      var d = textRange.GetPropertyValue(Paragraph.FlowDirectionProperty).ToString(); 
      rtlBtn.IsChecked = d == "RightToLeft"; 
     } 
    } 

Vous devez vous assurer que TextRange appartient au paragraphe que vous attendiez et que la propriété de ce reallu est définie sur RightToLeft.