简体   繁体   中英

RichTextBox setting Xaml Property Content in Silverlight

I have the following piece of code i made-up the purpose being this is used in a DataTemplate of a ListBox

<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" />

where the Xaml property gets set by the xaml content ( a string ) thats comes from the database.

Now i have wired javascript error when i try to set the xaml

this is the xaml content im trying to set RichTextBox.Xaml to,

<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>

any help is greatly appropriated, thanks!

在此位置有一个很棒的解决方案,希望这可以帮助每个解决我的Silverlight RichTextBox问题的人http://blogs.catapultsystems.com/asills/archive/2010/11/17/fun-with-attached-properties-% E2%80%93-bindable-richtextbox-xaml.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM