DocxDataProvider

3 posts, 0 answers
  1. Lukas
    Lukas avatar
    20 posts
    Member since:
    Jul 2011

    Posted 21 Feb 2012 Link to this post

    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. Lukas
    Lukas avatar
    20 posts
    Member since:
    Jul 2011

    Posted 21 Feb 2012 Link to this post

    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.
  3. Martin Ivanov
    Admin
    Martin Ivanov avatar
    104 posts

    Posted 22 Feb 2012 Link to this post

    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 >>
Back to Top