RichTextEditor.xaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <UserControl x:Class="InABox.DynamicGrid.RichTextEditor"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:sf="http://schemas.syncfusion.com/wpf"
  7. mc:Ignorable="d"
  8. d:DesignHeight="450" d:DesignWidth="800">
  9. <UserControl.Resources>
  10. <sf:FontFamilyStringConverter x:Key="FontFamilyStringConverter" />
  11. <sf:UnderlineToggleConverter x:Key="UnderlineToggleConverter" />
  12. <sf:LeftAlignmentToggleConverter x:Key="LeftAlignmentToggleConverter" />
  13. <sf:RightAlignmentToggleConverter x:Key="RightAlignmentToggleConverter" />
  14. <sf:CenterAlignmentToggleConverter x:Key="CenterAlignmentToggleConverter" />
  15. <sf:JustifyAlignmentToggleConverter x:Key="JustifyAlignmentToggleConverter" />
  16. </UserControl.Resources>
  17. <Border BorderBrush="DarkGray" BorderThickness="0.75" CornerRadius="2">
  18. <Grid>
  19. <Grid.RowDefinitions>
  20. <RowDefinition Height="Auto"/>
  21. <RowDefinition Height="*"/>
  22. </Grid.RowDefinitions>
  23. <ToolBar x:Name="Toolbar" Grid.Row="0" IsTabStop="False">
  24. <ComboBox Margin="12 2 0 2" Focusable="False" Width="160" x:Name="FontFamilyComboBox"
  25. SelectionChanged="fontFamilyCombo_SelectionChanged"
  26. ItemsSource="{Binding Path=FontFamilySource}" />
  27. <ComboBox Margin="12 2 0 2" IsTabStop="False" Width="45" x:Name="FontSizeComboBox" SelectedIndex="3"
  28. ItemsSource="{Binding Path=FontSizeSource}" IsEditable="True"
  29. TextBoxBase.TextChanged="fontSizeCombo_TextChanged"/>
  30. <Separator/>
  31. <ToggleButton x:Name="BoldBtn"
  32. Command="EditingCommands.ToggleBold"
  33. CommandTarget="{Binding ElementName=RtbEditor}"
  34. IsTabStop="False"
  35. Margin="2"/>
  36. <ToggleButton x:Name="ItalicBtn"
  37. Command="EditingCommands.ToggleItalic"
  38. CommandTarget="{Binding ElementName=RtbEditor}"
  39. IsTabStop="False"
  40. Margin="2"/>
  41. <ToggleButton x:Name="UnderlineBtn"
  42. Command="EditingCommands.ToggleUnderline"
  43. CommandTarget="{Binding ElementName=RtbEditor}"
  44. IsTabStop="False"
  45. Margin="2"/>
  46. <Separator/>
  47. <ToggleButton x:Name="AlignLeftBtn"
  48. Command="EditingCommands.AlignLeft"
  49. CommandTarget="{Binding ElementName=RtbEditor}"
  50. IsTabStop="False"
  51. Margin="2"/>
  52. <ToggleButton x:Name="AlignCenterBtn"
  53. Command="EditingCommands.AlignCenter"
  54. CommandTarget="{Binding ElementName=RtbEditor}"
  55. IsTabStop="False"
  56. Margin="2"/>
  57. <ToggleButton x:Name="AlignRightBtn"
  58. Command="EditingCommands.AlignRight"
  59. CommandTarget="{Binding ElementName=RtbEditor}"
  60. IsTabStop="False"
  61. Margin="2"/>
  62. <ToggleButton x:Name="AlignJustifyBtn"
  63. Command="EditingCommands.AlignJustify"
  64. CommandTarget="{Binding ElementName=RtbEditor}"
  65. IsTabStop="False"
  66. Margin="2"/>
  67. <Separator/>
  68. <Button x:Name="HyperlinkBtn"
  69. Click="HyperlinkBtn_Click"
  70. IsTabStop="False"
  71. Margin="2"/>
  72. </ToolBar>
  73. <!--sf:ToolBarAdv x:Name="Toolbar" DockPanel.Dock="Top" Focusable="False" GripperVisibility="Collapsed"
  74. Grid.Row="0"
  75. IsOverflowOpen="False">
  76. <ComboBox Margin="12 2 0 2" Focusable="False" Width="160" x:Name="fontFamilyCombo"
  77. SelectedValue="{Binding Path=Selection.CharacterFormat.FontFamily, Mode=TwoWay, ElementName=Editor, Converter={StaticResource FontFamilyStringConverter}}"
  78. ItemsSource="{Binding Path=FontFamilySource}" />
  79. <ComboBox Margin="12 2 0 2" IsTabStop="False" Width="45" x:Name="fontSizeCombo" SelectedIndex="3"
  80. ItemsSource="{Binding Path=FontSizeSource}"
  81. SelectedValue="{Binding Path=Selection.CharacterFormat.FontSize ,Mode=TwoWay,ElementName=Editor}" />
  82. <sf:ColorPickerPalette x:Name="fontColorPicker" Margin="12 2 0 2" IsTabStop="False" Width="60"
  83. IsExpanded="False" MoreColorOptionVisibility="Collapsed"
  84. StandardPanelVisibility="Collapsed"
  85. Color="{Binding Path=Selection.CharacterFormat.FontColor ,Mode=TwoWay,ElementName=Editor}" />
  86. <sf:ToolBarItemSeparator Margin="12 2 0 2" />
  87. <sf:ButtonAdv x:Name="Hyperlink" Margin="12 2 0 2" Focusable="False" SizeMode="Small"
  88. Command="sf:SfRichTextBoxAdv.ShowHyperlinkDialogCommand"
  89. CommandTarget="{Binding ElementName=Editor}" />
  90. <sf:ButtonAdv x:Name="Picture" Margin="12 2 0 2" Focusable="False" SizeMode="Small"
  91. Command="sf:SfRichTextBoxAdv.InsertPictureCommand"
  92. CommandTarget="{Binding ElementName=Editor}" />
  93. <sf:ButtonAdv x:Name="Table" Margin="12 2 0 2" Focusable="False" SizeMode="Small"
  94. Command="sf:SfRichTextBoxAdv.ShowInsertTableDialogCommand"
  95. CommandTarget="{Binding ElementName=Editor}" />
  96. <sf:ToolBarItemSeparator Margin="12 2 0 2" />
  97. <sf:ButtonAdv x:Name="ZoomIn" Margin="12 2 0 2" Focusable="False" SizeMode="Small"
  98. SmallIcon="pack://application:,,,/Resources/zoomin.png" Click="ZoomIn_Click" />
  99. <sf:ButtonAdv x:Name="ZoomOut" Margin="12 2 0 2" Focusable="False" SizeMode="Small"
  100. SmallIcon="pack://application:,,,/Resources/zoomout.png" Click="ZoomOut_Click" />
  101. </sf:ToolBarAdv-->
  102. <!--sf:SfRichTextBoxAdv x:Name="Editor" DockPanel.Dock="Top" EnableMiniToolBar="False"
  103. ContentChanged="RichTextBoxAdv_ContentChanged" BorderThickness="0"
  104. LostFocus="RichTextBoxAdv_LostFocus" OverridesDocumentBackground="True"
  105. LayoutType="Continuous"
  106. VerticalScrollBarVisibility="False"
  107. Grid.Row="1"
  108. RequestNavigate="Editor_RequestNavigate"/-->
  109. <RichTextBox x:Name="RtbEditor"
  110. SelectionChanged="RtbEditor_SelectionChanged"
  111. TextChanged="RtbEditor_TextChanged"
  112. Grid.Row="1"/>
  113. </Grid>
  114. </Border>
  115. </UserControl>