tags:

views:

590

answers:

2
A: 

The half answer is to set the IsDocumentEnabled property on the RichTextBox to true. That allows controls within it to be enabled as per Embedded UI Elements in RichTextBox. Unfortunately that still doesn't fire the event I need which is the GotFocus on a TableCell although it is possible to get the event to fire by putting a button in the cell and clicking on it. That bubbles the GotFocus event up the UI tree to the TableCell. I don't want a button in every cell though so time to look for an alternative solution.

<RichTextBox IsDocumentEnabled="True">
    <FlowDocument>
        <Table>
            <Table.Columns> 
                <TableColumn />
            </Table.Columns>
            <TableRowGroup>
                <TableRow>
                    <TableCell GotFocus="SelectionCell_GotFocus">
                        <BlockUIContainer>
                            <Canvas>
                                <Button Click="Button_Click">
                                    Click
                                </Button>
                            </Canvas>
                        </BlockUIContainer>
                    </TableCell>
                </TableRow>
            </TableRowGroup>
        </Table>
    </FlowDocument>
</RichTextBox>
sipwiz
A: 

did you ever solve this issue? I found about the IsDocumentEnabled="True" but I have the same requirement as I want to be able to insert table rows where the user clicks

Update I did find the following (at: http://www.databaseforum.info/8/504107.aspx) TRIED AND IT WORKS:

ContentElement, one of the base classes of Paragraph and incidentally the base class of just about everything that lives in a document defines the properties and events you are looking for.

In Code

void MyCode() 
{
    Paragraph p = new Paragraph();
    p.MouseEnter += p_MouseEnter;
}

void p_MouseEnter(object sender, EventArgs e) 
{
    Paragraph p = (Paragraph)sender;
    p.Background = Brushes.Red;
}

**In Markup**

<Paragraph MouseEnter="p_MouseEnter" />

**You can also trigger on properties like IsMouseOver in styles**
Tab