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:
Here's a pretty simple example for you.
Window1.xaml:
Name:
Age:
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 _propertyDescriptors = new List();
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