Mega Code Archive

 
Categories / VB.Net / WPF
 

Programmatically change the FlowDirection of content within a FlowDocumentReader element

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"   x:Class="WpfApplication1.Window1" Title="FlowDirection Sample">     <DockPanel HorizontalAlignment="Left" VerticalAlignment="Top">       <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,10">         <Button Click="LR">LeftToRight</Button>         <Button Click="RL">RightToLeft</Button>       </StackPanel>       <TextBlock Name="txt1" DockPanel.Dock="Bottom" Margin="0,50,0,0"/>       <FlowDocumentReader>         <FlowDocument FontFamily="Arial" Name="tf1" >           <Paragraph>this is a test</Paragraph>           <Paragraph>this is a test</Paragraph>       </FlowDocument>       </FlowDocumentReader>     </DockPanel> </Window> //File:Window.xaml.vb Imports System Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Documents Namespace WpfApplication1   Public Partial Class Window1     Inherits Window     Public Sub LR(sender As Object, e As RoutedEventArgs)       tf1.FlowDirection = FlowDirection.LeftToRight       txt1.Text = "FlowDirection is now " + tf1.FlowDirection.ToString()     End Sub     Public Sub RL(sender As Object, e As RoutedEventArgs)       tf1.FlowDirection = FlowDirection.RightToLeft       txt1.Text = "FlowDirection is now " + tf1.FlowDirection.ToString()     End Sub   End Class End Namespace