Well
I made Custom Control(richtextbox)
problem is that can not render in xaml after saving, somthing like this displayed (xaml code)
<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="/NRA.ClientLibrary;component/Fonts/Fonts.zip#BPG Glaho" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" CharacterSpacing="0" Typography.AnnotationAlternates="0" ........ that my RichTextBox look like this ...
<ComboBox SelectionChanged="cmbFontSizes_SelectionChanged" Width="45"> <ComboBoxItem Content="8" Tag="8"/> <ComboBoxItem Content="9" Tag="9"/> <ComboBoxItem Content="10" Tag="10"/> <ComboBoxItem Content="11" Tag="11" IsSelected="True"/> <ComboBoxItem Content="12" Tag="12"/> <ComboBoxItem Content="14" Tag="14"/> <ComboBoxItem Content="16" Tag="16"/> <ComboBoxItem Content="18" Tag="18"/> <ComboBoxItem Content="20" Tag="20"/> <ComboBoxItem Content="22" Tag="22"/> <ComboBoxItem Content="24" Tag="24"/> <ComboBoxItem Content="26" Tag="26"/> <ComboBoxItem Content="28" Tag="28"/> <ComboBoxItem Content="36" Tag="36"/> <ComboBoxItem Content="48" Tag="48"/> <ComboBoxItem Content="72" Tag="72"/> </ComboBox> <ComboBox SelectedIndex="0" SelectionChanged="cmbFontColors_SelectionChanged" Width="55"> <ComboBoxItem Tag="FFFF0000"> <Rectangle Width="22" Height="14" Fill="Red" Margin="2,0,0,0" /> </ComboBoxItem> <ComboBoxItem Tag="FF008000"> <Rectangle Width="22" Height="14" Fill="Green" Margin="2,0,0,0" /> </ComboBoxItem> <ComboBoxItem Tag="FF0000FF"> <Rectangle Width="22" Height="14" Fill="Blue" Margin="2,0,0,0" /> </ComboBoxItem> <ComboBoxItem Tag="FFFFFF00"> <Rectangle Width="22" Height="14" Fill="Yellow" Margin="2,0,0,0" /> </ComboBoxItem> <ComboBoxItem Tag="FF000000" IsSelected="True"> <Rectangle Width="22" Height="14" Fill="Black" Margin="2,0,0,0" /> </ComboBoxItem> </ComboBox> <StackPanel Orientation="Horizontal"> <!--Font Formatting Buttons--> <Button x:Name="btnBold" Padding="5 0" Click="btnBold_Click"> <TextBlock Text="B" FontWeight="Bold" FontFamily="Georgia" FontSize="14" /> </Button> <Button x:Name="btnItalic" Padding="5 0" Click="btnItalic_Click"> <TextBlock Text="I" FontWeight="Bold" FontFamily="Georgia" FontSize="14" FontStyle="Italic" /> </Button> <Button x:Name="btnUnderline" Padding="5 0" Click="btnUnderline_Click"> <TextBlock Text="U" FontWeight="Bold" FontFamily="Georgia" FontSize="14" TextDecorations="Underline" /> </Button> </StackPanel> </StackPanel> <ScrollViewer x:Name="scrollViewer" VerticalScrollBarVisibility="Auto" Padding="0"> <RichTextBox x:Name="richTextBox" ContentChanged="richTextBox_ContentChanged" AcceptsReturn="True" TextWrapping="Wrap" Height="75" Background="Transparent" BorderThickness="0"/> </ScrollViewer> </StackPanel> Code Behind
public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(RichTextBoxEditor), new PropertyMetadata(null, OnTextPropertyChanged)); private static void OnTextPropertyChanged(DependencyObject re, DependencyPropertyChangedEventArgs e) { RichTextBoxEditor richEdit = (RichTextBoxEditor)re; if (richEdit.richTextBox.Xaml != (string)e.NewValue) { try { richEdit.richTextBox.Blocks.Clear(); if (string.IsNullOrEmpty((string)e.NewValue) == false) { richEdit.richTextBox.Xaml = (string)e.NewValue; **here throws Exception: ArgumentException was caught ' value '** } } catch { richEdit.richTextBox.Blocks.Clear(); if (string.IsNullOrEmpty((string)e.NewValue) == false) { richEdit.richTextBox.Selection.Text = (string)e.NewValue; } } } } private void richTextBox_ContentChanged(object sender, ContentChangedEventArgs e) { Text = richTextBox.Xaml; } did anyone have this kind of problem??
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog