2010-04-21 51 views
0

我想讓用戶在RichTextBox中創建一個表。我可以在RichTextBox中創建一個Grid,但是我遇到了一些問題。如何訪問Silverlight 4中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> 

請注意,網格已經變成一個空的Run元素。

任何人都知道爲什麼會發生這種情況?

回答

0

事實證明,Silverlight 4中的RichTextBox.Xaml Property不包含InlineUIElements。文件中有關於它的說明。

請注意,由Xaml屬性返回的XAML字符串將不包含任何存在於內容中的UIElement對象。 InlineUIContainer對象將被轉換爲空的運行對象。

相關問題