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

System.NullReferenceException

1 Answer 43 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Iron
Veteran
Heiko asked on 05 Mar 2013, 05:45 PM
I try to bind a RadRichTextBox via DocxDataProvider to a byte buffer in my ViewModel. However I run into a NullReferenceException. This happens during initialization (Docx property, BindingState: UpdatingSource) before any relevant part of my code is executed.

This is how I set up the DocxDataProvider:

<telerikDocx:DocxDataProvider x:Name="docxProvider"
                      Docx="{Binding Buffer, Mode=TwoWay}"
                      RichTextBox="{Binding ElementName=radRichTextBox}"
                      SetupDocument="docxProvider_OnSetupDocument">
</telerikDocx:DocxDataProvider>

The Buffer is defined as:

private byte[] _buffer;
public byte[] Buffer
{
    get
    {
        return this._buffer;
    }
    set
    {
        this._buffer = value;
        this.RaisePropertyChanged(() => Buffer);
    }
}

I just load the view, set the DataContext to my ViewModel and that's all. When I set a breakpoint on the binding expression I can see that "Buffer" has the value of byte[0]. StackTrace says this happens at Telerik.Windows.Documents.FormatProviders.BinaryDataProviderBase.UpdateBytes()

I am really stuck with this problem and don't know how to solve it.

Regards
Neils

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 08 Mar 2013, 04:28 PM
Hello Neils,

I am not sure what might be the problem. Please find attached a project demonstrating how binding can be implemented using DocxDataProvider.

In case this does not help, please share some more details on your setup or even better, open a support ticket and send us a sample project we can use for troubleshooting.

Let us know how it goes.

All the best,
Petya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Heiko
Top achievements
Rank 1
Iron
Veteran
Answers by
Petya
Telerik team
Share this question
or