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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:49:35+00:00 2026-05-28T05:49:35+00:00

I want to create a custom control that extends a built-in control and then

  • 0

I want to create a custom control that extends a built-in control and then has a template that wraps that control with a container?

The C# class:

class ExtraBorderTextBox : TextBox {}

The Xaml:

<ControlTemplate>
    <Border>
        <TextBox/>
    </Border>
</ControlTemplate>

That doesnt’ work because the TextBox in the control template isn’t my custom control, it is a second instance.

I need access to the properties and events on TextBox, having a different parent doens’t make sense, I would have to replicate all of that in my class.

This is a simplified example; imagine Border being replaced with a ContentControl that has a 50 line control template for itself. I guess I want something like ContentPresenter (like I have in the ContentControl), but there isn’t anything like a “ControlPresenter”. Right? Am I missing something, or am I stuck with replicating my content control for the TextBox, or replicating the TextBox behaviour and presentation for my content control?

Thanks.

Update:
There is an answer here that does what I want, which is to copy the default template for System.Windows.Controls.TextBox. This will do what I want; I can insert my container into that. I was hoping that WPF provided a way that is more maintainable to do something like this, something like a adorner/decorator pattern.

Is there any way to make this better in some way? Would using something like Expression Blend make this so that I don’t have to hand-edit the XAML pasted in from the webpage?

  • 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-28T05:49:35+00:00Added an answer on May 28, 2026 at 5:49 am

    You could use the default control template as a base and modify it. The default control templates can be found here: http://msdn.microsoft.com/en-us/library/aa970773.aspx

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

Sidebar

Related Questions

I want a create a custom/user control that has children. For Example, I want
I want to create custom WPF control that has a single child control inside.
I want to create my own custom control that is basically a TableLayoutPanel with
I am attempting to create a custom server control CollapsablePanel that extends ASP.net's Panel.
I want to create a custom control that have the same behavior as what
I want to create custom Textbox control in asp.net.But i have one doubt when
I want to create a custom control type that behaves exactly like a ListBox
Lets pretend that for some reason I want to create a custom control that
I want to create a custom UIProperty Control that is not more than a
I want to create custom control (let's name it DesignPanel ) that will allow

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.