Question

In WPF, you can bind against ExpandoObject and other dynamic types:

    dynamic o = new ExpandoObject();
    o.Foo = "Hello";
    DataContext = o;

<TextBlock Text="{Binding Foo}"/>

This doesn't work in Silverlight 5. Is there a way to make it work or does anyone have links to this issue?

Was it helpful?

Solution

In Silverlight 5 they didn't add a default mechanism for binding to dynamic objects and instead added a new interface ICustomTypeProvider. And that interface wasn't added to an ExpandoObject either, but with expando you should be able to use the indexer binding since it is an IDictionary<string, object> that implements INotifyPropertyChanged.

<TextBlock Text="{Binding [Foo]}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top