<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.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace WpfApplication1
{
public partial class Window1 : Window
{
public void LR(object sender, RoutedEventArgs e)
{
tf1.FlowDirection = FlowDirection.LeftToRight;
txt1.Text = "FlowDirection is now " + tf1.FlowDirection.ToString();
}
public void RL(object sender, RoutedEventArgs e)
{
tf1.FlowDirection = FlowDirection.RightToLeft;
txt1.Text = "FlowDirection is now " + tf1.FlowDirection.ToString();
}
}
}
|