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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:45:31+00:00 2026-05-17T20:45:31+00:00

I was recently having some issues with a bigger project, but in an effort

  • 0

I was recently having some issues with a bigger project, but in an effort to solve the problem, I made a new solution with just two incredibly basic files. It is a WPF C# project with the main window containing a button, and a usercontrol containing a textblock. I already have them linked in Blend so that when I click the button, the usercontrol comes up. However, when I added code to change the text in the usercontrol’s textblock from the mainwindow, it gives me this error: An object reference is required for the non-static field, method, or property TestingUserControls.TestControl.sampleText.get’

I like usercontrols and we are using them all throughout our project, but for some reason I just cannot get them to work well.

The code for my usercontrol is this:

public TestControl()
        {
            this.InitializeComponent();
        }

        public string sampleText
        {
            get { return blkTest.Text; }
            set { blkTest.Text = value; }
        }

The code for the main window is this:

public MainWindow()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            TestControl.sampleText.set("Sup");
        }
  • 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-17T20:45:31+00:00Added an answer on May 17, 2026 at 8:45 pm

    There are two issues here:

    1. You are trying to use an instance property as though it were a static property.
    2. The syntax you are employing to invoke a property-setter is not correct.

    Make sure you have a reference to an instance of TestControl. For example, you can use the WPF designer to drag an icon representing the control from the toolbox onto the main-window, and then change the body of the handler to:

    testControl1.sampleText = "Sup";
    

    In this case, testControl1 is a field, which references an instance of your control.

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

Sidebar

Related Questions

I have recently started looking into using Azure but I'm having some issues getting
I bought a new Vista PC recently but was having lots of problems getting
I created a calendar with Datepicker, but recently I'm having some trouble with it.
Having recently worked on a project which required some more IO interaction than I'm
I recently upgraded a VB 6 project to .net. I'm having a problem with
Recently, I found myself having to write up some concerns I have about race
This is a weird problem I have started having recently. My team is developing
Recently, I've started having a problem with my SQL Server 2005 client running on
I’m looking for some advice. I recently wrapped up a project where I inherited
I'm working on a proprietary site, and I'm having some issues. I'm using jQuery

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.