【发布时间】:2012-04-13 22:44:54
【问题描述】:
我有一个名为 ApplicationUser 的自定义类,它有许多属性。这里重要的是 GivenName 和 Surname。
在窗口的 ctor 中,我有返回名为 _allUsers 的列表的代码。此调用成功,列表中填充了适当数量的 ApplicationUsers
然后我会做类似的事情:
_allUsers = CachingLayer.Get<List<ApplicationUser>>("allUserInformation");
cboListOfUsers.DataContext = _allUsers;
还有 XAML:
<ComboBox Name="cboListOfUsers" ItemsSource="{Binding}" IsEnabled="{Binding Path = IsChecked, ElementName=rbAssignedTo}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<TextBlock.Text >
<MultiBinding StringFormat=" {0}, {1} ">
<Binding Path="Surname" />
<Binding Path="GivenName" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
但是没有乐趣(组合框仍然是空的)
我在这里做错了什么?
【问题讨论】:
-
查看您的输出窗口,看看是否有任何绑定错误。
-
尝试去掉 IsEnabled 部分。
-
@Blam - 我已经尝试将其关闭,抱歉没有指定...
-
@m-y 输出窗口中没有明显的绑定错误
-
@m-y 现在得到 System.Windows.Data 警告:40:BindingExpression 路径错误:在“对象”“ApplicationUser”(HashCode=257207)上找不到“GivenName”属性。绑定表达式:路径=给定名称; DataItem='ApplicationUser' (HashCode=257207);目标元素是'TextBlock'(名称='');目标属性是我的输出窗口中的“文本”(输入“字符串”)错误