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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:20:59+00:00 2026-05-30T11:20:59+00:00

I have case where the class hierarchy is something like this, +—————+ | UIElement

  • 0

I have case where the class hierarchy is something like this,

   +---------------+
   | UIElement     |
   |---------------|                            +----------------------+
   | ...           |                            | My Windows Application
   | SomePropert{} |                            |----------------------|
   |               |<---+                       |+--------------------+|
   |               |    |                       ||MyUserControl       ||
   +---------------+    |                       ||--------------------||
         +--------------+-----+                 ||                    ||
         |FrameWorkElement    |                 |+--------------------+|
         |--------------------|                 |//Want to use         |
         |    ...             |<-+              |// SomeProperty;      |
         +--------------------+  |              |                      |
                     +-----------+-+            |                      |
                     |Control      |            |                      |
                     |-------------|            +----------------------+
                     |  ...        |<---+
                     +-------------+    |
                            +-----------+---+
                            | UserControl   |
                            |---------------|<---+
                            |  ...          |    |
                            +---------------+    |
                                      +----------+-------+
                                      | MyUserControl    |
                                      |------------------|
                                      | SomeProperty{}   |
                                      | //Want to override
                                      |                  |
                                      +------------------+

Now in my app (and all other apps where I can export this MyUserControl) can I set the SomeProperty that is handled by the MyUserControl class rather than UIElement?

I am right now doing this by creating an object to MyUserControl and assigning that to the control that I added in my xaml page.So right now looks like this,

MyUserControl newControl = new MyUserControl();
web = windowsPhoneControl11;  //windowsPhoneControll1 is the 
                              //one that I added from toolbox.
                              // i.e., mycustomecontrol added from toolbox.

So now since I am using the ‘new’ it gets overriden. But when I export this control I can’t expect the user to create a new object and assign it to the control that one is using in the xaml page.

So is there any other way I could override this one property so that the assignment of that property is handled by MyUserControl class rather than the UIElement class? What I mean about MyUserControl having the control to set this property is that I need to check for some value before assigning it. If it is not atleast an expected value then I need to set it to a default value.

Ps: I am sorry for such a long question but I couldn’t express it more precise and I was not able to find anyother question related to this. And it is WindowsPhoneApp… Not the ordinary windowsapplication.

  • 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-30T11:21:00+00:00Added an answer on May 30, 2026 at 11:21 am

    Forgive me if I’ve interpreted this incorrectly but would the following work:

    public class BaseClass
    {
        public int MyProperty
        {
           get; set;
        }
    }
    public class ChildClass : BaseClass
    {
        public new int MyProperty
        {
           get
           {
               return base.MyProperty;
           }
           set
           {
               if(DoYourCheckingStuff(value))
               {
                   base.MyProperty = value;
               }
           }
        }
    }
    

    Didn’t test this.

    Although this feels like a really hack-ish way of doing it. What property are you actually trying to ‘have control’ over? Since there may be easier ways of doing this.

    An example: Change a UserControl so that it’s width can’t be set between 100 and 200 (Although this is probably a pretty bad way to do it), by hiding it’s Width property:

    public class MyUserControl : UserControl
    {
        public new double Width
        {
            get
            {
                return base.Width;
            }
            set
            {
                 if(!(value > 100 && value < 200))
                     base.Width = value;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a hierarchy that looks something like this: class Base { public: void
A have a class hierarchy that looks somethign like this: class AbstractDataType { public:
I have a hierarchy like the following: case class A(val a: Long, val b:
I have something like following: public interface A { .... } public abstract class
I have a class hierarchy like so: (=> means is a subclass of) anonymous
We have a class hierarchy similar to this one: public class TestDereference { private
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
For example is it better to have: public class Case : EntityIdentifiable { public
I have the following use case: There's a class called Template and with that
Case One Say you have a little class: class Point3D { private: float x,y,z;

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.