1

我创建了一个新窗口并尝试将我的类设置FooService为 DataContext 属性。但在“选择对象”对话框中,我只能找到一些类,而不能找到FooService.

如果对要在该对话框中列出的类有任何要求,有什么想法吗?

4

2 回答 2

2

FooService 是否有一个公共的无参数构造函数?如果没有,Blend 将看不到它。

于 2012-06-12T12:33:02.420 回答
0

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".

于 2012-06-11T20:54:42.893 回答