2015-03-02 82 views
0

是否有與ListBox.ItemTemplate等價的RichTextBox?是否有與ListBox.ItemTemplate等價的RichTextBox?

<ListBox.ItemTemplate> 
    <DataTemplate> 
    <Grid> 
     <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" SharedSizeGroup="Col0"/> 
     <ColumnDefinition Width="Auto" SharedSizeGroup="Col1"/> 
     <ColumnDefinition Width="Auto" SharedSizeGroup="Col2"/> 
     </Grid.ColumnDefinitions> 
     <TextBlock Grid.Column="0" Text="{Binding tabType}"/> 
     <TextBlock Grid.Column="1" Text="{Binding tabPhone}"/> 
     <TextBlock Grid.Column="2" Text="{Binding tabLast}"/> 
    </Grid> 
    </DataTemplate> 

這ListBox.ItemTemplate加上一個類(tabType {得到;集;})組織顯示成列。


50分鐘後編輯。

上述列表框代碼導致三列。目標是讓一個RichTextBox具有三列。

+0

你能說明你在找什麼嗎? ListBox的ItemTemplate指定列表框中的每個項目將如何顯示。 「RichTextBox」中的等效效果是什麼,指定每個字符的顯示方式? – 2015-03-02 19:30:39

+0

也許嘗試發佈一張圖片來說明你之後的效果,並解釋爲什麼你似乎使用** RichTextBox **控件來設置它。 – 2015-03-03 15:11:48

回答

0

您在RichTextBox中使用FlowDocument並使用Table控件來顯示錶格或網格狀數據。請參閱下面的代碼。

<RichTextBox Margin="10"> 
     <FlowDocument> 
      <Table>     
       <Table.Columns> 
        <TableColumn /> 
        <TableColumn /> 
        <TableColumn /> 
       </Table.Columns>     
       <TableRowGroup>      
        <TableRow> 
         <TableCell>         
          <Paragraph>Cell at Row 1 Column 1</Paragraph> 
         </TableCell> 
         <TableCell> 
          <Paragraph>Cell at Row 1 Column 2</Paragraph> 
         </TableCell> 
         <TableCell> 
          <Paragraph>Cell at Row 1 Column 3</Paragraph> 
         </TableCell> 
        </TableRow> 
        <TableRow> 
         <TableCell> 
          <Paragraph>Cell at Row 2 Column 1</Paragraph> 
         </TableCell> 
         <TableCell> 
          <Paragraph>Cell at Row 2 Column 2</Paragraph> 
         </TableCell> 
         <TableCell> 
          <Paragraph>Cell at Row 2 Column 3</Paragraph> 
         </TableCell> 
        </TableRow> 
       </TableRowGroup> 
      </Table> 
     </FlowDocument> 
    </RichTextBox> 

在LisBox我們可以綁定到集合,但在這裏我不知道如何實現在RichTextBox中和表相同。

相關問題