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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:29:36+00:00 2026-05-25T10:29:36+00:00

I have a little problem and can´t find any solution. Maybe it is an

  • 0

I have a little problem and can´t find any solution. Maybe it is an issue in Visual Studio.

I have created a new class that is inherited from Image. I then override the Source property.

class GifImage : Image
{
     public new ImageSource Source
     {
         get { return base.Source; } 
         set
         {
             MesssageBox("new source property");
             base.Source = value;
         } 
     }
}

If I set Source in code

GifImage gifImage = new GifImage();
gifImage.Source = gifimage2;

Then the Source will be correctly set to GifImage and the MessageBox will be shown.

But if I set Source in the Xaml-Code:

<my1:GifImage Stretch="Uniform" Source="/WpfApplication1;component/Images/Preloader.gif" />

Then the Source property of the Image will be set and the MessageBox won´t be shown.

My idea was to set the System.ComponentModel.Browsable-Attribute, thinking that maybe the property in the inherit GifImage class is not visible in Visual Studio and it is using the source property of the parent class.

[Browsable(true)]
public new ImageSource Source

But this is still not working.

Has somebody had the same problem or/and the solution for this?

  • 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-25T10:29:36+00:00Added an answer on May 25, 2026 at 10:29 am

    You are not able to override a DependencyProperty in that manner in WPF.

    As the Source property on an Image is a DependencyProperty, when the value is assigned in XAML (and other places) it’s value is set using

    DependencyObject.SetValue(SourceProperty, value)
    

    One possible solution is to override the metadata of the DependencyProperty and add change listener, e.g.

        static GifImage()
        {
            SourceProperty.OverrideMetadata(typeof(GifImage), new FrameworkPropertyMetadata(new PropertyChangedCallback(SourcePropertyChanged)));
    
        }
    
        private static void SourcePropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            MessageBox("new source property");
        }
    

    or alternativly using the DependencyPropertyDescriptor

    DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(Image.SourceProperty, typeof(Image));
    if (dpd != null)
    {
       dpd.AddValueChanged(tb, delegate
       {
           MessageBox("new source property");
       });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey guys, somehow i can't find the solution for my little problem. i have
I have a little problem and I don't find any solutions. In my asp.net
I have a little problem with a Listview. I can load it with listview
I have this little problem, that I cannot figure out which arguments to pass
I have a little problem with threads in Erlang NIFs. You can view my
While I can find the answer to almost any specific question I have concerning
I have created a little Python egg (with setuptools) that I want to install
I have run into a problem with generics in Java and I can't find
I have a little problem with setuptools/easy_install; maybe someone could give me a hint
i have little problem with boost::asio library. My app receive and process data asynchronously,

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.