Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:39:24+00:00 2026-05-16T14:39:24+00:00

public class RichTextBoxExtended : RichTextBox { static RichTextBoxExtended() { //DefaultStyleKeyProperty.OverrideMetadata(typeof(RichTextBoxExtended), new FrameworkPropertyMetadata(typeof(RichTextBoxExtended))); } public

  • 0
public class RichTextBoxExtended : RichTextBox
{
    static RichTextBoxExtended()
    {
        //DefaultStyleKeyProperty.OverrideMetadata(typeof(RichTextBoxExtended), new FrameworkPropertyMetadata(typeof(RichTextBoxExtended)));
    }

    public byte[] Text
    {
        get { return (byte[])GetValue(TextProperty); }
        set { SetValue(TextProperty, value); }
    }

    // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty TextProperty =
        DependencyProperty.Register("Text", typeof(byte[]), typeof(RichTextBoxExtended), new UIPropertyMetadata(null, new PropertyChangedCallback(TextChangedCallback)));

    private static void TextChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArgs e)
    {
        RichTextBoxExtended richTextBoxExtended = obj as RichTextBoxExtended;
        richTextBoxExtended.ChangeText(e);
    }

    private void ChangeText(DependencyPropertyChangedEventArgs e)
    {
        //clear out any formatting properties
        TextRange range = new TextRange(base.Document.ContentStart, base.Document.ContentEnd);
        range.ClearAllProperties();

        //load bytes into stream, load stream into range
        MemoryStream stream = new MemoryStream(e.NewValue as byte[]);
        range.Load(stream, DataFormats.Rtf);
    }
}

Above is the custom control…

XAML implementing custom control…

<Grid>
    <controls:RichTextBoxExtended x:Name="Document" Text="{Binding Path=File}">
    </controls:RichTextBoxExtended>
</Grid>

Associated VM…

public class FileViewerViewModel : AViewModel
{
    private byte[] _file = null;

    public FileViewerViewModel(ILoggerFacade logger)
    {

    }

    /// <summary>
    /// Gets or sets the <seealso cref="DataFormats.Rtf"/> file representation as a <seealso cref="byte[]"/>
    /// </summary>
    public byte[] File
    {
        get 
        {
            return _file;
        }
        set 
        {
            _file = value;
            RaiseChanged(() => this.File);
        }
    }
}

Finally..if I call…

FileViewerView view = _container.Resolve<FileViewerView>();

It fails.

Resolution of the dependency failed, type = "cyos.infrastructure.Views.FileViewerView", name = "". Exception message is: The current build operation (build key Build Key[cyos.infrastructure.Views.FileViewerView, null]) failed: Object reference not set to an instance of an object. (Strategy type BuildPlanStrategy, index 3)

If I remove the binding from within the XAML…

<Grid> 
    <controls:RichTextBoxExtended x:Name="Document">
    </controls:RichTextBoxExtended>
</Grid>

Everything works without a hitch…no problems at all…ideas?

EDIT:

Switched to creating a new instance, bypassing Unity. Issue is still in the same place, exception at construction of FileViewerView at InitializeComponent() with “Object reference not set to an instance of an object.”

at System.Windows.Markup.BamlRecordReader.ProvideValueFromMarkupExtension(MarkupExtension markupExtension, Object obj, Object member)
at System.Windows.Markup.BamlRecordReader.ReadPropertyArrayEndRecord()
at System.Windows.Markup.BamlRecordReader.ReadRecord(BamlRecord bamlRecord)
at System.Windows.Markup.BamlRecordReader.Read(Boolean singleRecord)
at System.Windows.Markup.TreeBuilderBamlTranslator.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
at cyos.infrastructure.Views.FileViewerView.InitializeComponent() in c:\Documents and Settings\amciver\My Documents\dev\cyos\cyos\cyos.infrastructure\Views\FileViewerView.xaml:line 1
at cyos.infrastructure.Views.FileViewerView..ctor(FileViewerViewModel viewModel) in now…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:39:26+00:00Added an answer on May 16, 2026 at 2:39 pm

    I don’t know what the problem with array, but List<byte> works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class CovariantTest { public A getObj() { return new A(); } public static
public class Order { static Customer cust = new Customer(); string sEmpty = ;
public class InterruptedInput { public static void main(String[] args) { InputThread th=new InputThread(); //worker
public class Base{ protected String str; public static final Base ERROR = new Base(error);
public class Main { public static void main(String []ar) { A m = new
Public Class FooBar { private int _foo; public int Foo { get { return
public class Test{ public void Test(String name){}; public static void main() { Test t=new
public class Options { public FolderOption FolderOption { set; get; } public Options() {
public class TestBL { public static void AddFolder(string folderName) { using (var ts =
public class MySingletonClass { public MySingletonClass() { _mySingletonObj = Instance(); } public static MySingletonClass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.