wpf - 项目控件绑定不显示任何内容?
问题描述
出于某种原因,我的 XAML 没有为我的项目控件显示任何内容。我使用学生列表作为我的 ItemsSource 并引用该列表的属性来创建自定义控件。
这是我的 XAML:
<ItemsControl ItemsSource="{Binding Class.Students}" Grid.Row="1">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ComboBox>
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="500"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock Text="{Binding FavoriteSubject, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
现在,下拉菜单是空的。绑定是正确的,如果我将它们拉到 ItemsControl 之外,它们会显示得很好。我缺少关于 ItemsControls 的某些特定内容吗?
解决方案
推荐阅读
- mysql - MYSQL 5.1.51-community Stored Procedure with if statement
- buildroot - 从其他目录运行 Omake
- php - Laravel:静态文件名问题的路由
- azure-functions - Azure Function + Application Insights - 不跟踪 SQL 查询
- forms - 嵌入表单集合。空结果
- javascript - 模态存在但正文仍在滚动
- pytest - 制作自定义测试结果
- java - 在 SpringBoot application.properties 中设置文件的相对路径不起作用
- node.js - 节点获取失败,但也可以
- javascript - Regex to match string with exact number of identifier characters