我有以下代码片段,目的是将它用于ListBox的DataTemplate
<RichTextBox Name="RichTextBoxPostContent" TextWrapping="Wrap" Margin="0" Padding="8,8,8,0" IsReadOnly="True" Background="{x:Null}" BorderThickness="0" VerticalScrollBarVisibility="Auto" Xaml="{Binding PostContent}" AcceptsReturn="True" />
其中Xaml属性由来自数据库的xaml内容(字符串)设置。
现在我尝试设置xaml
时出现了有线javascript错误这是我尝试将RichTextBox.Xaml设置为
的xaml内容<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="31" Text="This" /><Run Text=" " /><Run FontWeight="Bold" Text="is" /><Run Text=" " /><Run FontSize="26" FontStyle="Italic" Text="a" /><Run Text=" " /><Run FontWeight="Normal" FontStyle="Italic" Text="test " /><Run Text="post " /><Hyperlink Foreground="#FF337CBB" TextDecorations="Underline" NavigateUri="http://google.com" MouseOverForeground="#FFED6E00"><Run Text=":)" /></Hyperlink></Paragraph></Section>
任何帮助都非常合适,谢谢!
答案 0 :(得分:0)
在这个位置有一个很棒的解决方案希望这可以帮助每个人处理Silverlight RichTextBox的问题 http://blogs.catapultsystems.com/asills/archive/2010/11/17/fun-with-attached-properties-%E2%80%93-bindable-richtextbox-xaml.aspx