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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:01:35+00:00 2026-05-13T02:01:35+00:00

I see several people saying that WPF can use Custom Type Descriptors for Change

  • 0

I see several people saying that WPF can use “Custom Type Descriptors” for “Change notification”.

The ways I know how to do Change Notification are:

object.GetBindingExpression(Bound.property).UpdateTarget();

Or have my object implement INotifiyPropertyChanged.

I see comments saying that Custom Type Descriptors will work too, but no one gives a good example on how it works. I am now asking for that example (IE a good example of WPF Data Binding and updating via Custom Type Descriptors.)

  • 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-13T02:01:35+00:00Added an answer on May 13, 2026 at 2:01 am

    Here’s a pretty simple example for you.

    Window1.xaml:

    <Window x:Class="CTDExample.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
    
            <TextBlock>Name:</TextBlock>
            <TextBox Grid.Column="1" Text="{Binding Name}"/>
    
            <TextBlock Grid.Row="1">Age:</TextBlock>
            <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Age}"/>
    
            <TextBlock Grid.Row="2" Grid.ColumnSpan="2">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} is {1} years old.">
                        <Binding Path="Name"/>
                        <Binding Path="Age"/>
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </Grid>
    </Window>
    

    Window1.xaml.cs:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Windows;
    
    namespace CTDExample
    {
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
    
                var ctd = new CTD();
                ctd.AddProperty("Name");
                ctd.AddProperty("Age");
                DataContext = ctd;
            }
        }
    
        public class CTD : CustomTypeDescriptor
        {
            private static readonly ICollection<PropertyDescriptor> _propertyDescriptors = new List<PropertyDescriptor>();
    
            public void AddProperty(string name)
            {
                _propertyDescriptors.Add(new MyPropertyDescriptor(name));
            }
    
            public override PropertyDescriptorCollection GetProperties()
            {
                return new PropertyDescriptorCollection(_propertyDescriptors.ToArray());
            }
    
            public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
            {
                return GetProperties();
            }
    
            public override EventDescriptorCollection GetEvents()
            {
                return null;
            }
    
            public override EventDescriptorCollection GetEvents(Attribute[] attributes)
            {
                return null;
            }
        }
    
        public class MyPropertyDescriptor : PropertyDescriptor
        {
            private readonly IDictionary<object, object> _values;
    
            public MyPropertyDescriptor(string name)
                : base(name, null)
            {
                _values = new Dictionary<object, object>();
            }
    
            public override bool CanResetValue(object component)
            {
                throw new NotImplementedException();
            }
    
            public override Type ComponentType
            {
                get { throw new NotImplementedException(); }
            }
    
            public override object GetValue(object component)
            {
                object value = null;
                _values.TryGetValue(component, out value);
                return value;
            }
    
            public override bool IsReadOnly
            {
                get { return false; }
            }
    
            public override Type PropertyType
            {
                get { return typeof(object); }
            }
    
            public override void ResetValue(object component)
            {
                throw new NotImplementedException();
            }
    
            public override void SetValue(object component, object value)
            {
                var oldValue = GetValue(component);
    
                if (oldValue != value)
                {
                    _values[component] = value;
                    OnValueChanged(component, new PropertyChangedEventArgs(base.Name));
                }
            }
    
            public override bool ShouldSerializeValue(object component)
            {
                throw new NotImplementedException();
            }
    
            public override void AddValueChanged(object component, EventHandler handler)
            {
                // set a breakpoint here to see WPF attaching a value changed handler
                base.AddValueChanged(component, handler);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say a table has several subclass types. How can I see all columns from
I am doing a maprouting application. Several people have suggested me, that I do
First, I know this question has been asked several times before and that in
Hey people. I see that this topic is repeated over and over on SO
I have a small solution that i provide to several people. The solution consists
We have a system that handles several users where users can spend up to
I see several programmers, including Apple, creating codes where they declare stuff like this:
Why Unicode has several reserved character codes? See the Unicode for two languages- Kannada
I have an application that has several stores , and each store has several
In several pieces of sample objective-c code I've seen people create new objects like

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.