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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:27:30+00:00 2026-05-14T15:27:30+00:00

I am writing code that will populate the Margin , Padding and BorderThickness properties

  • 0

I am writing code that will populate the Margin, Padding and BorderThickness properties of classes in the System.Windows.Documents namespace. Each of these properties accepts a value in the form of a System.Windows.Thickness, which is a struct.

However, I wish to associate some additional data with each of these property assignments, which may subsequently be retrieved by my code. If Thickness were a class, I would inherit from it and define properties in the subclass to store my additional data items. But since it is a struct, inheritance is not possible.

Is there any practical way to achieve this, while maintaining type-compatibility with the properties I am populating?

Thanks for your ideas,

Tim

  • 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-14T15:27:30+00:00Added an answer on May 14, 2026 at 3:27 pm

    There are no good alternatives.

    Depending on what you are trying to do, you could perhaps define your own class with the properties you need, and define the implicit conversion operator to do a implicit conversion to the correct struct type. Then you would be able to pass in your class to all methods expecting a Thickness parameter.

    This would go against the recommendation of using the implicit conversion operator, though, since it states that the implicit conversion should not lose any information. You will not be able to get the Thickness back from the property you are reading, and see the extra information you attached.

    This is how you could implement it:

    public class ThicknessEx
    {
        public string ExtraData { get; set; }
        public Thickness Thickness { get; set; }
    
        public static implicit operator Thickness(ThicknessEx rhs)
        {
            return rhs.Thickness;
        }
    }
    

    However, you are probably better off by storing the extra data elsewhere. How to do it would depend on your needs and application.

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

Sidebar

Ask A Question

Stats

  • Questions 386k
  • Answers 386k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To get a character from string you can use -characterAtIndex:… May 14, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer Use digits of size 2^k. To extract the nth digit:… May 14, 2026 at 11:42 pm
  • Editorial Team
    Editorial Team added an answer How about using anonymous objects? So for example you could… May 14, 2026 at 11:42 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.