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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:46:18+00:00 2026-05-15T21:46:18+00:00

As I stated in another post , I access at times controls direct from

  • 0

As I stated in another post, I access at times controls direct from the code behind. If I do this I name the controls as I do also in ControlTemplates and DataTemplates, I give them the prefix PART_ and after that I precise the name, for example…

<TextBox Name=”PART_UserName” />

Is this against a common WPF naming scheme? Formerly I used the prefix m_ followed by the description…

<TextBox Name=”m_userName” />

.. because in reality its exactly this, but I don’t liked it.
What do you think?
Please note, I don’t want to discuss whether to use MVVM or not. There are situations I don’t care about.

  • 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-15T21:46:19+00:00Added an answer on May 15, 2026 at 9:46 pm

    The pattern PART_<name> is used when you write custom controls that can be retemplated. These are the names of mandatory parts of the template, without which the control cannot work. Such names are usually declared with a [TemplatePart] attribute in C# code :

    [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
    [TemplatePart(Name = "PART_UpButton", Type = typeof(Button))]
    [TemplatePart(Name = "PART_DownButton", Type = typeof(Button))]
    public class NumericUpDown : Control
    {
        ...
    
         protected override OnApplyTemplate()
         {
             base.OnApplyTemplate();
    
             // Find controls in the template
             TextBox textBox = Template.FindName("PART_TextBox", this) as TextBox;
             Button upButton = Template.FindName("PART_UpButton", this) as Button;
             Button downButton = Template.FindName("PART_DownButton", this) as Button;
    
             // Do something with the controls...
             ...
         }
    
        ...
    }
    

    So unless you’re writing a control template, there’s no reason to use that naming pattern. Just name your controls whatever you like, as long as it makes sense for you.

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

Sidebar

Related Questions

I recently wrote another post on this same topic in which I was not
So, I have this variable that I push into the controller via POST from
In a comment on another post , @JonathanLeffler stated that: { ... } |
I originally started this question in another thread, but that thread was sorta, kinda
I re-posted this question as I think it is a bit vague. New Post
I know this question might be repeated many times but would really appreciate any
I have two repeaters that looks like this : Arrange By: Name | Age
I had another post started: Rack / Passenger fails on Dreamhost but after some
Please forgive me if this post is in the wrong place, but as your
Hello people from StackOverflow! I come to you with yet another question. :) As

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.