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 4042280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:59:09+00:00 2026-05-20T12:59:09+00:00

Using WPF and Prism. I have a view, containing 1 textblock <UserControl x:Class=ArmoryModule.Views.ResultsView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

  • 0

Using WPF and Prism.

I have a view, containing 1 textblock

<UserControl x:Class="ArmoryModule.Views.ResultsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Views="clr-namespace:ArmoryModule.Views" xmlns:vmdc="clr-namespace:ArmoryModule.ViewModels"
             mc:Ignorable="d">

    <UserControl.DataContext>
        <vmdc:ResultsViewModel />
    </UserControl.DataContext>

    <Grid>
        <TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
    </Grid>
</UserControl>

attempting to bind to the pertinent part of ResultsViewModel below

class ResultsViewModel : ViewModel
{
    private Character _character;

    public Character Character
    {
        get { return _character; }
        set
        {
            if (_character != value)
            {
                _character = value;
                RaisePropertyChanged(() => Name);
            }
        }
    }

    public string Name
    {
        get { return _character.Name; }
    }
}

Builds fine, breaks at startup. I get an object ref not sent to an instance of an object error on

get { return _character.Name; }

I know character isn’t populated at startup and thats the reason I’m getting the above error. I am kind of clueless as where to create Character so that the 2 viewmodels I have can use it.

  • 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-20T12:59:09+00:00Added an answer on May 20, 2026 at 12:59 pm

    Either add it to the constructor for the view model

    public ResultsViewModel()
    {
        _character = new Character();
    }
    

    or simply add a check in the getter, e.g.

    get
    {
        return _character != null ? _character.Name : string.empty;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which I am developing using WPF\Prism\MVVM. All is going well
Im using prism 4.0, wpf, I create RegionAdapter for devx DocumentGroup. I have a
I am creating an application using WPF which is using Prism framework. I have
I have an application all done in WPF, using MvvM/Prism/Unity and Remote as datasource.
We have the beginnings of a modular wpf application built using prism. We want
I have an application written using Prism 4.0. It has lots of Views which
My application is build in C#4, using Prism (CAL) and WPF. We have the
I've just started learning WPF MVVM using Prism and Unity. Decoupling the view from
I'm new to Prism, but I have successfully built several WPF/Mvvm-Light applications. I'm using
I have a Main WPF application and other modules and I am using PRISM

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.