This is a migrated thread and some comments may be shown as answers.

DocxDataProvider

2 Answers 167 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lukas
Top achievements
Rank 1
Lukas asked on 21 Feb 2012, 10:58 AM
Hi there,

am I right that a DocxDataProvider released with the Q1 '12 package? I'm trying to bind against it from a RadDocument in my VM to the DocxDataProvider in my XAML which looks like this:

<telerikDocx:DocxDataProvider Docx="{Binding RadDocument, Mode=TwoWay}" RichTextBox="{Binding ElementName=editor}" x:Name="dataProvider" />

But it doesn't work properly. The RichTextBox stays empty.

UPDATE:
I've analyzed the code a bit more. The RadDocument property gets bound before it gets filled. But after it's been filled the "NotifyOfPropertyChange" (Caliburn) it gets bound again. I debugged this. I thought maybe the document itself is empty, but it's not. It contains a section with 20 paragraphs.

UPDATE 2:
I thought the solution is, that I don't bind the actual RadDocument, but rather to the exported RadDocument:

VM:
private RadDocument _myDoc;
public RadDocument MyDoc
{
    get
    {
        return _myDoc;
    }
    set
    {
        _myDoc = value;
        NotifyOfPropertyChange(() => MyDoc);
    }
}
 
private byte[] _myBytes;
public byte[] MyBytes
{
    get { return new DocxFormatProvider().Export(MyDocument); }
}
 
// ctor
ctor()
{
    MyDoc = GetDocumentSomehow();
}

My XAML looks like this:

<telerik:RadRichTextBox IsReadOnly="{Binding IsReadOnly}" x:Name="editor" AllowDrop="True" Drop="editor_Drop" />
<telerikDocx:DocxDataProvider Docx="{Binding MyBytes}" RichTextBox="{Binding ElementName=editor}" x:Name="dataProvider" />

2 Answers, 1 is accepted

Sort by
0
Lukas
Top achievements
Rank 1
answered on 21 Feb 2012, 12:06 PM
Sorry for the double post, but I always continued typing in my last code block - I couldn't get under it.

The solution was the order in my XAML. The data provider MUST be declared BEFORE the richtextbox.
0
Martin Ivanov
Telerik team
answered on 22 Feb 2012, 05:19 PM
Hello Lukas,
We are glad that you found a solution to your problem.

Don't hesitate to contact us if you have other questions.

Greetings,
Martin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Lukas
Top achievements
Rank 1
Answers by
Lukas
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or