I'm looking to bind to a class that exposes its properties dynamically as per the code below. It seems that both ICustomTypeProvider and DynamicObject would work for this. Can anybody explain why I might want to use one over the other?
void CreateDynamicItem()
{
var di = new DynamicItem();
di.AddProperty("Age", 16, typeof(int));
di.AddProperty("Height", 5.2, typeof(double));
}
<StackPanel>
<Slider Value="{Binding Age}" />
<Slider Value="{Binding Height}" />
</StackPanel>
I found the answer here Binding to Dynamic Properties with ICustomTypeProvider under "What about WPF and DLR?"