如何在 Silverlight 4 中访问 RichTextBox 内的网格?
我试图允许用户在 RichTextBox 内创建表格。我可以在 RichTextBox 内创建一个网格,但我遇到了一些问题。
我从网格中的 XAML 开始。
<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>
然后,当我使用 RichTextBox 的 Xaml 属性获取 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="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>
请注意,此处的 Grid 已变成一个空的 Run 元素。
有谁知道为什么会发生这种情况?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明 Silverlight 4 中的 RichTextBox.Xaml 属性 不包括 InlineUIElements。文档中有对此的注释。
As it turns out the RichTextBox.Xaml Property in Silverlight 4 doesn't include the InlineUIElements. There is a note about it in the documents.