Menu

XAML, Blend & Binding to Static Data Sources

July 9, 2008 - WPF / XAML
XAML, Blend & Binding to Static Data Sources

I’ve just been having a little play around with some methods for binding UI elements (in this case a ComboBox) to static data sources. As you may know Blend offers a UI to set up data binding to CLR objects (this is accessed from the main Blend UI using the [+CLR Object] button in the Data window. I had setup a Static class with a Static member that is an ObservableCollection<T>. However, when clicking on the [+CLR Object] this static class is not displayed as a potential data binding source. This is odd since this is a perfectly workable solution using this kind of binding syntax in XAML.

[source:xml]
[/source]

I’m trying to find out why this is the case since Blend should in theory just display this class as a potential datasource for the ComboBox and allow the user to bind to it. You can see this in action if you download the solution I created whilst trying this out:

Download XAML Static Class Binding Example

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

*