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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:32:56+00:00 2026-05-27T01:32:56+00:00

The title is a bit blur here, I didn’t find a way to say

  • 0

The title is a bit blur here, I didn’t find a way to say it more clearly.

Let’s take a simple and very clear example of my situation:

First: I have a custom control, FooControl , with a DependencyProperty of type IFoo. The control is supposed to display IFoo objects in a DataGrid

Please note that, of course, the real object is not just about displaying some values, I could have used just a DataGrid for this matter 😉

public class FooControl : DataGrid
{
        /// <summary>
        /// Foo!
        /// </summary>
        public static readonly DependencyProperty FooProperty =
            DependencyProperty.Register("Foo",
                                        typeof(IFoo),
                                        typeof(FooControl),
                                        new PropertyMetadata(FooChanged));

Second: I have an IFoo interface

public interface IFoo
{
    IList<double> Values { get; set; }
}

Third: I have a Foo object, implementing IFoo

public class Foo : IFoo
{
    public IList<double> Values { get; set; }
}

And now, I want an ObservableFoo, for binding updates purpose, here it is:

public class ObservableFoo : Foo, INotifyCollectionChanged
{
    public ObservableCollection<double> ObservableValues {get; set; }
}

Now, THE PROBLEM:

I usually have my FooControls bound to objects of type Foo, which are “strict” implementations of the IFoo interface.
Now, I also need to have three FooControls which should be bound to objects of type ObservableFoo (which obviously are IFoo, but also add a property not specified in the interface, ie ObservableValues )

in the FooControl class, I manually set a binding to the values to be displayed:

    /// <summary>
    /// Sets the binding on foo values
    /// </summary>
    /// <param name="propertyPath">Binding path</param>
    public void SetValuesBinding(string propertyPath)
    {
        // Binding for foovalues
        Binding fooBinding = new Binding(propertyPath);
        fooBinding.Converter = new FooConverter();
        fooBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
        fooBinding.RelativeSource = new RelativeSource(RelativeSourceMode.Self);
        fooBinding.Mode = BindingMode.TwoWay;

        this.SetBinding(FooControl.ItemsSourceProperty, fooBinding);
    }

When propertyPath is Foo.Values , it works fine, updating the binding’s target will call the PropertyChangedHandler I defined for ItemsSource

When propertyPath is Foo.ObservableValues, updating the binding won’t call the PropertyChangedHandler I defined. However, there is no Binding error displayed on the output window!

In my comprehension of the problem, it means that:

  • The Binding “worked”, ie. it has found the source property
  • BUT, since ObservableValues is not in IFoo but only in ObservableFoo, the binding tries to find IFoo.ObservableValues and… cannot update it.

How could I manage to update the binding to ObservableValues ?

I hope I made it clear enough for you guys. Please feel free to ask any question if you need me to clarify

  • 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-27T01:32:57+00:00Added an answer on May 27, 2026 at 1:32 am

    Okay, I finally went for a workaround.

    I Added a property to the FooControl :

        /// <summary>
        /// The values displayed
        /// </summary>
        public System.Collections.IEnumerable ValuesToDisplay
        {
            get
            {
                if (this.Foo is ObservableFoo)
                {
                    return (this.Foo as ObservableFoo).ObservableValues;
                }
                else if (this.Foo == null)
                {
                    return null;
                }
                else
                {
                    return this.Foo.Values;
                }
            }
        }
    

    And I bind the embedded Datagrid’s ItemSource to this property (using a RelativeSource pointing to itself) and… It works fine.

    But still, this made me learn something: binding does not resolve types at runtime, it will just take the specified type apparently!

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

Sidebar

Related Questions

My title is a bit vauge, here's the problem I'm talking about. Say I
The title is a bit vague, but let me tell you what I want
Ok, the title is a bit confusing, but here's my predicament. I've made a
The title is a bit difficult to put together for this question. Say I
The title is a bit confusing but here's what I'm after: I have a
(Title sounds a bit too fancy but I couldn't find a match so we'll
Ok, the wording of the title is a bit odd but I didn't really
So I know I butchered the title a bit but if someone looks here
The title is a bit misleading maybe; my spellchecker focuses more on format than
Ok I know the title is a bit confusing but here is my problem:

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.