I’m using the new RichTextBox control in SL4Beta and want to create styles for paragraphs and runs (blocks and inlines). I noticed that I can create a style for a <Block/>, like so:
<Style x:Key="lvl2Paragraph" TargetType="Block">
<Setter Property="FontFamily" Value="Times New Roman"/>
<Setter Property="FontStyle" Value="Italic"/>
<Setter Property="FontSize" Value="22"/>
</Style>
But I can’t set that to a <Paragraph/> as The member “Style” member is not recognized or not accessible. Like this:
<RichTextBox TextWrapping="Wrap">
<Paragraph Style="{StaticResource lvl2Paragraph}">
Can't set a style for a paragraph.
</Paragraph>
</RichTextBox>
Is there anyway to make “Style” exposed for the RichTextBox? I’m open to all ideas.
Styleis a property and mechanism supported by elements that inherit fromFrameworkElement. However the contents ofRichTextBoxare lightweight, they do not haveFrameworkElementor evenUIElementin their class ancestory.The only way I can think of to mitigate this is to create an Attached property to take the place of the missing
Styleproperty. However you would have implement in that attached property all the setting of the other properties. It would sensitive to document order if inline Xaml also sets the same properties.