如何在 Silverlight 4 中访问 RichTextBox 内的网格?

发布于 2024-08-29 21:07:16 字数 1926 浏览 4 评论 0原文

我试图允许用户在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春风十里 2024-09-05 21:07:16

事实证明 Silverlight 4 中的 RichTextBox.Xaml 属性 不包括 InlineUIElements。文档中有对此的注释。

请注意,Xaml 属性返回的 XAML 字符串将不包含内容中存在的任何 UIElement 对象。 InlineUIContainer 对象将转换为空 Run 对象。

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.

Note that The XAML string returned by the Xaml property will not include any UIElement objects that are present in the content. The InlineUIContainer objects will be converted to empty Run objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文