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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:02:18+00:00 2026-05-16T10:02:18+00:00

I have a custom control called TextBoxWithLabelAndUnits . From the name, you can tell

  • 0

I have a custom control called TextBoxWithLabelAndUnits. From the name, you can tell that it’s a TextBox that has a Label before it and a Label after it, so that the custom control looks like this:

       -----------------
Label: |               | units
       -----------------

I expose several dependency properties to configure the control, such as:

LabelWidth
LabelText
UnitText
TextBoxWidth

Now I have a user control called LatLong that I’m using for Latitude/Longitude input. The XAML looks like this:

<UserControl ...>
    <StackPanel>
        <TextBoxWithLabelAndUnits LabelText="Latitude:"
                                  UnitText="degrees"
        />
        <TextBoxWithLabelAndUnits LabelText="Longitude:"
                                  UnitText="degrees" 
        />
    </StackPanel>
</UserControl>

It will create a user control that looks like this:

           -----------------
Latitude:  |               | degrees
           -----------------
           -----------------
Longitude: |               | degrees
           -----------------

Now I want to use my user control in a project. However, I’d like the user control to expose properties so I can change the labels if I don’t like the default settings. I can expose each one as a new dependency property to look like this:

LatitudeLabelWidth
LatitudeLabelText
LatitudeUnitText
LatitudeTextBoxWidth

LongitudeLabelWidth
LongitudeLabelText
LongitudeUnitText
LongitudeTextBoxWidth

And the XAML for something that uses a LatLong control will look like this:

<Window ...>
    <LatLong LatitudeLabelText="Latitude (in degrees)"
             LatitudeUnitText=""
             LongitudeLabelText="Longitude (in degrees)"
             LongitudeUnitText=""
    />
</Window>

But that seems like a lot of work since I have to re-expose every dependency property for each instance. I was wondering if there was an easier way that exposes the TextBoxWithLabelAndUnits instance itself, so I can edit the properties directly on it and use XAML that looks like this:

<Window ...>
    <LatLong Latitude.LabelText="Latitude (in degrees)"
             Latitude.UnitText=""
             Longitude.LabelText="Longitude (in degrees)"
             Longitude.UnitText=""
    />
</Window>

So in other words, rather than exposing the properties on each custom control inside the user control, I expose the custom control itself and get access to all the properties using dot notation.

Does anybody know if that’s possible to do in WPF?

  • 1 1 Answer
  • 1 View
  • 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-16T10:02:19+00:00Added an answer on May 16, 2026 at 10:02 am

    Sure — why don’t you just give your LatLong these two properties?

    public TextBoxWithLabelAndUnits LatitudeControl
    {
        get { return latitude; }
    }
    
    public TextBoxWithLabelAndUnits LongitudeControl
    {
        get { return longitude; }
    }
    

    Then they will be directly accessible through code.

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

Sidebar

Related Questions

I have a Custom Control that has multiple textbox fields and a checkbox contained
I have a custom control that inherits from UserControl , and I can't get
I have a user control called GameButton that has a label inside it. When
I have a custom user control called ErrorNotificationBox. To place that on my page
I have a custom control that inherits from .NET's CompositeControl class. This control overrides
I have a custom control in an aspx page that has a property named
I'm creating a custom control called FooControl derived from ItemsControl have a default style
I have a custom WPF user control called a TimeoutPanel that I am trying
I have custom control that extends DataGrid . It is called ExtendedDataGrid . I
i have a custom layout called myWebView that is extended from WebView. class myApp{

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.