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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:15:12+00:00 2026-05-31T16:15:12+00:00

How can I create a user control like the Textbox? For example when I

  • 0

How can I create a user control like the Textbox? For example when I change the Text property of a Textbox control the new text appears on the window that I am currently working with.

In my project I have a lot of places where the user has to enter information therefore I want to create a InputField user control. (that usercontrol consists of a label an a textbox with custom style)

Here is the xaml for my user control:

<UserControl x:Class="PDV.UserControls.InputField"
         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" 
         mc:Ignorable="d" >
   <Grid>
      <StackPanel>
          <Label Content="{Binding Path=LblContent}" HorizontalAlignment="Left" VerticalAlignment="Top"  />
          <TextBox Height="23" Margin="5,-5,2,2" Name="textBox1" VerticalAlignment="Top" />
      </StackPanel>
   </Grid>
</UserControl>

and the code behind for that user control:

namespace PDV.UserControls
{
    public partial class InputField : UserControl
    {
        public static DependencyProperty MessageProperty = DependencyProperty.Register(
            "LblContent", typeof(string), typeof(UserControl));

        public string LblContent{
            get{
                return (string)GetValue(MessageProperty);
            }
            set{
                SetValue(MessageProperty, value);
            }
        }

        //Constructor
        public InputField(){
            InitializeComponent();
            this.DataContext = this;
        }
    }
}

so on my main window I will be able to use that user control by:

1) importing the namespace where that user control is:

  xmlns:myCtrl ="clr-namespace:PDV.UserControls"

2) placing that control in that window:

  <myCtrl:InputField LblContent="hello" Margin="0,0,483,0" Height="49" VerticalAlignment="Top"></myCtrl:InputField>

What do I have to do so that when I update LblContent="hello" it renders on the window? It will be nice for it to render at design time not just at runtime

  • 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-31T16:15:13+00:00Added an answer on May 31, 2026 at 4:15 pm

    I think that the second type of might be InputField
    public static DependencyProperty MessageProperty = DependencyProperty.Register(
    “LblContent”, typeof(string), typeof(InputField));

    I never try to set the DataContext in your way, eventually try to give a name at the usercontrol x:Name=”Root” then change the binding like this: Content=”{Binding Path=LblContent, ElementName=Root}”

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

Sidebar

Related Questions

I need to create a custom TextBox control that allows user input HTML tags.
I want to create a user control [textbox] which convert all the text in
I know how to create a custom user control in WPF but how can
I understand that you can now create MVC-specific user controls, but will my existing
How can create a New user in ORACLE with full access (alter, delete, select,
How can I create board for simple game, looks like for chess,but user could
Does anyone know of any software that can be used to create Agile User
I need to create a user control in C#.Net, which can be added to
I'm trying to create a user control that will provide a draggable splitter between
I have wpf user control <StackPanel Orientation=Horizontal> <TextBox Name=txbInterval Text=5/> <Image Name=imgStart Source=Images/start.png/> <Image

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.