Question

I've been following the Silverlight text editor sample with interest. It gives me a lot of functionality such as formatting, clipboard support, printing etc.

The sample also allows for DataGrids to be inserted by using an InlineUiContainer.

My problem is that the inserted DataGrid is disabled while my requirement is that the user can edit the contents of the DataGrid.

How can I make InlineUiContainers that are inserted in a RichTextBox enabled?

No correct solution

OTHER TIPS

The RichTextBox has to be ReadOnly to make controls respond to events. I got around this by making the RichTextBox be ReadOnly by default then become editable on focus.

My problem was having RichTextBoxes in a DataGrid which also has other controls embedded in each RichTextbox. It doesn't sound like your RTB can ever be out of focus ReadOnly since there will only be one RTB.

You'll have to think of some strategy that will put the RTB into ReadOnly mode under certain conditions.

I encountered the same problem and didn't find any answer online...

This is what i did, a bit ugly but it works:

Create a custom control and put the data grid inside. Add to the custom control the following code:

    public CustomControl()
    {
        InitializeComponent();


        this.IsEnabledChanged += EnableChanged;
    }

    private int counter = 0;
    private void EnableChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
        if (counter == 0)
        {
            this.IsEnabled = (bool) e.OldValue;
            counter = 1;
            return;
        }
        counter = 0;
    }

Good Luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top