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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:49:57+00:00 2026-05-13T18:49:57+00:00

Am i missing something here? I have created a usercontrol with a property and

  • 0

Am i missing something here? I have created a usercontrol with a property and for arguments sake it has a text box in it.

<UserControl x:Class="Isd.Utility.SystemMonitorWpf.Bar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<TextBlock x:Name="txtExpected" Grid.Column="0" Grid.ColumnSpan="2" Width="auto" Height="auto" FontSize="10" LayoutTransform="{StaticResource Rotate}" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Tahoma" Foreground="Red" Panel.ZIndex="100" Margin="5,5,5,5"/>

Then in the code behind i have

public partial class Bar : UserControl
{
    private string _PropTest;

    public string PropTest
    {
        get { return _PropTest; }
        set { _PropTest = value; }
    } 

public Bar()
    {
        InitializeComponent();
        txtExpected.Text = PropTest;
    }
}

Then i drop the usercontrol into the xaml and set the property to a value

<local:Bar PropTest="test"></local:Bar>

In this example, when the usercontrol is displayed the text is showing as null, its like the property PropTest never got set. Am I missing something obvious here? Thanks in advance.

  • 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-13T18:49:57+00:00Added an answer on May 13, 2026 at 6:49 pm

    You don’t appear to be doing anything in the setter of PropTest. It won’t be set prior to construction, so it will be null when you do:

    txtExpected.Text = PropTest;
    

    Inside your constructor. If you do this:

    public string PropTest
    {
        get { return _PropTest; }
        set 
        { 
            _PropTest = value; 
            txtExpected.Text = PropTest;
        }
    } 
    

    It should work. It’s not what I’d call an “ideal” way to do things though, you might want to take a look at Dependency Properties, INotifyPropertyChanged and Binding.

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

Sidebar

Related Questions

I have to be missing something obvious here. I don't get why this cast
I'm probably missing something very obvious here. I have files with the extension .st
I'm sure I'm missing something pretty simple here. I've created a custom DateTime display
I'm missing something here: $objSearcher = New-Object System.DirectoryServices.DirectorySearcher $objSearcher.SearchRoot = New-Object System.DirectoryServices.DirectoryEntry $objSearcher.Filter =
Now I must be missing something here, as this seems a very basic issue
I may be missing something here because I thought this might be really easy
Ok, maybe I'm missing something here but I'm looking at various PHP hosting options
I'm probably missing something simple here, but I can't find the answer elsewhere. I
No doubt I'm missing something really simple here but I just can't see the
I want to know if I'm missing something. Here's how I would do it:

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.