Table editing...On its Way!!

An interesting feature in editing is TableEditing. Everyone of us has created a table sometime or the other. So in light of its importance we included the table construct. However, the editing aspects are limited in the CPT release and hence, if you come across some glitches be assured that it will be addressed in the next release.

Now for some XAML code. Its pretty simple:

 <Grid xmlns='https://schemas.microsoft.com/winfx/avalon/2005' 
xmlns:x='https://schemas.microsoft.com/winfx/xaml/2005'>
<RichTextBox>
   <FlowDocument>
      <FlowDocument.Resources>         <Style TargetType='{x:Type TableCell}'>
            <Setter Property='BorderThickness' Value='1' />            <Setter Property='BorderBrush' Value='Black' />
         </Style>      </FlowDocument.Resources>      <Table BorderThickness="2" BorderBrush="BLUE">
         <TableRowGroup > 
            <TableRow >
                <TableCell ><Paragraph>Text</Paragraph></TableCell >
                <TableCell ><Paragraph>Text</Paragraph></TableCell >
            </TableRow>
            <TableRow >
                <TableCell ><Paragraph>Text</Paragraph></TableCell >
                <TableCell ><Paragraph>Text</Paragraph></TableCell >
            </TableRow>
         </TableRowGroup>
      </Table>
   </FlowDocument>
</RichTextBox>
</Grid> 

Image hosted by Photobucket.com

Lets look at the code. The table has a border color set and the same applies to the table cells. However, for the tablecells we use a style as this makes the code neater and easier to manage. By default, the border colors are the same as the background and this makes it difficult to identify the cells and the table itself.

Within the table we have a tableRowGroup and then the TableRows, which inturn contain tableCells. These cells must contain a Block to hold the content - So a valid contruct could be a Paragraph or a BlockUIContainer.

As for the editing aspects, we support the basic editing scenarios. So you can edit content within the cells, add rows, delete rows and so forth. And remember to have border colors ;)