Tarion
Tarion

Reputation: 17174

Can't bind to some objects in WPF using Expression Blend

I create a new Window and try to set my Class FooService as DataContext property. But in the "Select Object" dialog I can only find some of the classes but not the FooService.

Any Idea if there are any requirements for classes to be listed in that dialog?

Upvotes: 1

Views: 132

Answers (2)

Joel Cochran
Joel Cochran

Reputation: 7768

Does FooService have a public parameter-less constructor? If not, Blend won't see it.

Upvotes: 2

Trevor Elliott
Trevor Elliott

Reputation: 11252

You need to add the appropriate namespace to the list of XML namespaces in the XAML file for the Window.

For example, if your FooService class had a namespace of "Services" you would add an xmlns declaration like so:

<Window ...
        xmlns:services="clr-namespace:Services"
        ... />

or (if it's in a different project that you have referenced)

xmlns:services="clr-namespace:Services;assembly=Services"

Assuming that project's name is "Services".

Upvotes: 0

Related Questions