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

  • Home
  • SEARCH
  • 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'm missing something fundamental here. i have a very simple custom class that draws
I have to be missing something simple here but it escapes me. After the
I'm missing something fundamental here. I have a table view with each cell displaying
I hope I am not missing something very simple here. I have done a
I'm really new to SVN and seem to be missing something here... I have
I know I'm missing something here. In the XSLT transformation below, the actual result
Im sure I am missing something here but none the less. foo['bar'] = nil
I might be missing something here but am unable to understand the true purpose
I guess that I am missing something here. After having found this sample within
I am new to Moq, so hopefully I am just missing something here. For

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.