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

  • Home
  • SEARCH
  • 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 8253001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:43:26+00:00 2026-06-08T00:43:26+00:00

I have some simple Dependency Properties that are not working. I’ve looked over them,

  • 0

I have some simple Dependency Properties that are not working. I’ve looked over them, looked over code I’ve used in the past, and I’m not sure why they are not working.

I have a custom base class (MyBaseControl) that extends UserControl, and my custom UI controls then extend on that. For example, MyCustomControl extends MyBaseControl.

MyCustomControl XAML is simple enough:

<StackPanel>
    <Image Source="{Binding Icon}" />
    <TextBlock Text="{Binding Blurb}" />
</StackPanel>

MyCustomControl Code looks like this:

public partial class MyCustomControl: MyBaseControl
{
    //public static readonly DependencyProperty IconProperty = Image.SourceProperty.AddOwner(typeof(MyCustomControl));
    //public static readonly DependencyProperty BlurbProperty = TextBlock.TextProperty.AddOwner(typeof(MyCustomControl));

    public static readonly DependencyProperty IconProperty =
        DependencyProperty.Register(
        "Icon",
        typeof(ImageSource),
        typeof(MyCustomControl),
        new PropertyMetadata(null));

    public static readonly DependencyProperty BlurbProperty =
        DependencyProperty.Register(
        "Blurb",
        typeof(String),
        typeof(MyCustomControl),
        new PropertyMetadata(null));

    public MyCustomControl() : base()
    {
        InitializeComponent();
    }

    #region Properties

    public ImageSource Icon
    {
        get { return (ImageSource)GetValue(IconProperty); }
        set { SetValue(IconProperty, value); }
    }

    public String Blurb
    {
        get { return (String)GetValue(BlurbProperty); }
        set { SetValue(BlurbProperty, value); }
    }

    #endregion Properties
}

Notice that I’ve tried a few different ways to define the DependencyProperty. Neither works.

I call my control in the following way:

<ctrl:MyCustomControl Height="240" VerticalAlignment="Center" HorizontalAlignment="Center" Width="320" Blurb="Slide Show" Icon="pack://application:,,,/Resources/photo_scenery.png" />

If I set the Source or Text directly in the XAML, they show up just fine. The bindings are just not wanting to work properly.

What am I missing that is not allowing my bindings to pass through?

Thank you for any help!

UPDATE: I’ve updated the code based on comments and additional changes I’ve tried.

  • 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-06-08T00:43:29+00:00Added an answer on June 8, 2026 at 12:43 am

    You are registering Icon property incorrectly. In its registration method you need to specify the DP name i.e. in place of “IconProperty” it should be “Icon” –

    public static readonly DependencyProperty IconProperty =
            DependencyProperty.Register(
            "Icon",
            typeof(ImageSource),
            typeof(MyCustomControl),
            new PropertyMetadata(null));
    

    Also, try setting RelativeSource in your bindings like this –

    <StackPanel>
        <Image Source="{Binding Icon, RelativeSource={RelativeSource 
                Mode=FindAncestor, AncestorType={x:Type ctrl:MyCustomControl}}}" />
        <TextBlock Text="{Binding Blurb, RelativeSource={RelativeSource 
                Mode=FindAncestor, AncestorType={x:Type ctrl:MyCustomControl}}}" />
    </StackPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called Profile that has some simple properties and then it
I have some simple constraints involving multiplication of reals in z3 that are producing
I have some very simple XML: <properties> <property> <name>BobFish</name> <explaination>Bob is a fish.</explaination> </property>
I have some VERY simple code to return the title for a section header:
I have a complex WPF control that for some reasons (ie. performance) is not
I have a simple application that uses Spring 3 for dependency injection. I have
I have a simple data structure (the properties are of course Dependency Properties): class
A simple(and lengthy) question, and not a simple answer. Working with some DI frameworks(Spring,
I have some simple JQuery / Javascript to perform some simple logic for all
I have some simple markup: <table> <tr> <td>Menu Item</td> </tr> </table> <div> <table> <tr>

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.