Skip to content
Loading
  • 0
    How can I set it in xaml so that I can utilize full space while setting textblocks/content?
    0
  • Mukil Vendhan
    0
    kindly follow the link:https://msdn.microsoft.com/en-us/library/system.windows.documents.flowdocument.pagewidth(v=vs.110).aspx
    0
  • Manikandan Murugesan
    0
    You can change the dimension for A4
    1. <Window x:Class="WpfApplication1.Window1"  
    2.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    3.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    4.     Title="FlowDocument Optimal Paragraph Sample">  
    5.   <StackPanel>  
    6.         <CheckBox Click="ToggleHyphenation" Content="Automatic Hyphenation"/>  
    7.         <CheckBox Click="ToggleOptimalParagraph" Content="  Enable Optimal Paragraph Layout"/>  
    8.         <CheckBox Click="ToggleColumnFlex" Content="Enable Flexible Columns"/>  
    9.         <Slider Name="columnWidthSlider" ValueChanged="ChangeColumnWidth"/>  
    10.         <Slider Name="columnGapSlider" ValueChanged="ChangeColumnGap"/>  
    11.     <FlowDocumentReader Name="flowReader">  
    12.       <FlowDocument Name="flowDoc"        TextAlignment="Justify"   
    13.         IsOptimalParagraphEnabled="True"  IsHyphenationEnabled="True"  
    14.         IsColumnWidthFlexible="True"      Background="AliceBlue"  
    15.         ColumnWidth="300"                 ColumnGap="20">  
    16.         <Paragraph><Italic>this is a testItalic>Paragraph>  
    17.         <Paragraph>  
    18.           <Hyperlink NavigateUri="http://www-cs-faculty.stanford.edu/~knuth/">  
    19.             - Donald E. Knuth  
    20.           Hyperlink>  
    21.         Paragraph>  
    22.         <Paragraph><Bold>Principle of Optimal ParagraphBold>Paragraph>  
    23.         <Paragraph>this is a test <Italic>italicItalic> Paragraph>  
    24.         <Paragraph>this is a testParagraph>  
    25.         <Paragraph>this is a testParagraph>  
    26.         <Paragraph>this is a testParagraph>  
    27.       FlowDocument>  
    28.     FlowDocumentReader>  
    29.   StackPanel>  
    30. Window>  
    31.   
    32. //File:Window.xaml.cs  
    33.   
    34. using System;  
    35. using System.Windows;  
    36. using System.Windows.Controls;  
    37. using System.Windows.Data;  
    38. using System.Windows.Documents;  
    39. using System.Windows.Media;  
    40. using System.Windows.Shapes;  
    41.   
    42.   
    43. namespace WpfApplication1  
    44. {  
    45.     public partial class Window1 : Window  
    46.     {  
    47.   
    48.         void ToggleHyphenation(Object sender, RoutedEventArgs args)  
    49.         {  
    50.             flowDoc.IsHyphenationEnabled = ((CheckBox)sender).IsChecked.Value;  
    51.         }  
    52.   
    53.         void ToggleOptimalParagraph(Object sender, RoutedEventArgs args)  
    54.         {  
    55.             flowDoc.IsOptimalParagraphEnabled = ((CheckBox)sender).IsChecked.Value;              
    56.         }  
    57.   
    58.         void ToggleColumnFlex(Object sender, RoutedEventArgs args)  
    59.         {  
    60.             flowDoc.IsColumnWidthFlexible = ((CheckBox)sender).IsChecked.Value;  
    61.         }  
    62.   
    63.         void ChangeColumnWidth(Object sender, RoutedEventArgs args)  
    64.         {  
    65.                 if (columnWidthSlider.Value == 0)   
    66.                 {  
    67.                     flowDoc.ColumnWidth = 100;  
    68.                 }  
    69.                 else if (columnWidthSlider.Value == 1)  
    70.                 {  
    71.                     flowDoc.ColumnWidth = 200;  
    72.                 }  
    73.                 else if (columnWidthSlider.Value == 2)  
    74.                 {  
    75.                     flowDoc.ColumnWidth = 300;  
    76.                 }  
    77.                 else if (columnWidthSlider.Value == 3)  
    78.                 {   
    79.                     flowDoc.ColumnWidth = 400;   
    80.                 }  
    81.                 else if (columnWidthSlider.Value == 4)  
    82.                 {   
    83.                     flowDoc.ColumnWidth = 500;   
    84.                 }  
    85.   
    86.         }  
    87.         void ChangeColumnGap(Object sender, RoutedEventArgs args)  
    88.         {  
    89.        
    90.                 if (columnGapSlider.Value == 0)  
    91.                 {  
    92.                     flowDoc.ColumnGap = 5;  
    93.                 }  
    94.                 else if (columnGapSlider.Value == 1)  
    95.                 {  
    96.                     flowDoc.ColumnGap = 10;  
    97.                 }  
    98.                 else if (columnGapSlider.Value == 2)  
    99.                 {  
    100.                     flowDoc.ColumnGap = 15;  
    101.                 }  
    102.                 else if (columnGapSlider.Value == 3)  
    103.                 {  
    104.                     flowDoc.ColumnGap = 20;  
    105.                 }  
    106.                 else if (columnGapSlider.Value == 4)  
    107.                 {  
    108.                     flowDoc.ColumnGap = 25;  
    109.                 }  
    110.   
    111.         }  
    112.     }  
    113. }  
    114.   
    115. WPF Change Flow Document Width And Height 
    0