How to access a grid inside of a RichTextBox in Silverlight 4?
- by benrick
I am trying to allow a user to create a table inside of a RichTextBox. I can create a Grid inside of the RichTextBox, but I am having some issues with it.
I start with this XAML in the Grid.
<RichTextBox Name="TB1" AcceptsReturn="True">
<Paragraph TextAlignment="Center">
Hi everybody
</Paragraph>
<Paragraph>
<InlineUIContainer>
<Grid Background="Black">
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<RowDefinition Height="10" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition Width="10" />
</Grid.ColumnDefinitions>
</Grid>
</InlineUIContainer>
</Paragraph>
<Paragraph>
How are you today?
</Paragraph>
</RichTextBox>
Then when I get the XAML out using the Xaml property of the RichTextBox I get this 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="Center">
<Run Text="Hi everybody" />
</Paragraph>
<Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run />
</Paragraph>
<Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run Text="How are you today?" />
</Paragraph>
</Section>
Notice here that the Grid has turned into an empty Run element.
Anyone know why this happens?