- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有 3 张 table :
Item - 这是 DataContext - 它有一个导航列 Group
组 - 有一个导航列类别。
我想在 DataGrid 中包含两个(类别和组)列,当我选择一个类别时,它应该只在组 col 中显示 Category.Groups。
这是我正在处理的代码:
<tk:DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}">
<tk:DataGrid.Columns>
<!--Works-->
<tk:DataGridComboBoxColumn
Header="Categroy"
DisplayMemberPath="Title"
SelectedValuePath="CategoryId"
SelectedValueBinding="{Binding Group.Category.CategoryId}"
ItemsSource="{Binding Context.Categories,
Source={x:Static Application.Current}}"
/>
<!--Look at these two things:-->
<!--This does work-->
<tk:DataGridTemplateColumn>
<tk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl
ItemsSource="{Binding Group.Category.Groups}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type data:Group}">
<TextBlock Text="{Binding Title}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</tk:DataGridTemplateColumn.CellTemplate>
</tk:DataGridTemplateColumn>
<!--But this does NOT work, even it's the same source-->
<!--Notice I even tried a dummy converter and doesnt reach there-->
<tk:DataGridComboBoxColumn
Header="Group"
DisplayMemberPath="Title"
SelectedValuePath="GroupId"
ItemsSource="{Binding Group.Category.Groups,
Converter={StaticResource DummyConverter}}"
SelectedValueBinding="{Binding Group.GroupId}"
/>
</tk:DataGrid.Columns>
</tk:DataGrid>
{Binding}
与
DummyConverter
它不会在转换器中停止;在类别组合框中它工作正常。
最佳答案
数据网格中的列没有数据上下文,因为它们从未添加到可视化树中。听起来有点奇怪,但看看 vince's blog ,它是视觉布局的一个很好的例子。绘制网格后,单元格具有数据上下文,您可以使用普通绑定(bind)(不是静态资源..)在其中设置组合框项目源
您可以像这样访问组合框项目源:
<dg:DataGridComboBoxColumn>
<dg:DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Path=MyBindingPath}" />
</Style>
</dg:DataGridComboBoxColumn.EditingElementStyle>
</dg:DataGridComboBoxColumn>
关于wpf - 问题绑定(bind) DataGridComboBoxColumn.ItemsSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1724180/
我在 ListView 上使用 ItemsSource。我现在想使用 SQL 查询执行搜索和过滤项目,因此我重新分配了 ItemsSource;但随后抛出异常: 在使用 ItemsSource 之前,
我有一段代码不能正常工作。如果我执行一次 btnNew 就没有问题。如果我执行两次,我会得到一个错误... Operation is not valid while ItemsSource is in
我是 Binding 和 WPF 的新手,最近我学会了如何使用 Binding 技术创建一个包含多个列的 listBox
我的模型中有以下内容: public class Equipment { public enum Type { Detector, Vegetation
我已经创建了自己的集合并实现了 INotifyCollectionChanged。 public class ObservableSortedSet : SortedSet, INotifyColle
我有一个包含项目数组的 View 模型: public class FooViewModel { public FooListItem[] ListItems { get; set; }
如果 DataContext 更改 TabControl 没有反应 现在我必须在这里做每一个变化 tabControlRoom.ItemsSource = (IEnumerable)new Res
如何将枚举设置为 xaml 中的列表框。但是在列表框中,我需要显示描述而不是枚举的名称/值。然后,当我单击一个按钮时,我需要将选定的枚举通过 icommand 作为枚举而不是字符串传递给方法。 例如:
将组合框的 ItemsSource 设置为整数数组? 最佳答案 0 1 2
我的 TreeView 绑定(bind)到 ObservableCollection 并使用 HierarchicalDataTemplates。 我从网络服务中获取模型。 只有当用户单击树中的节点时
我的 WPF 应用程序中有一个 Datagrid 控件,我正在尝试将该控件绑定(bind)到我的主窗口类中的 ObservableCollection 属性。我试图绑定(bind)的属性定义为: pr
我正在写一个自定义 ItemsControl (一个选项卡式文档容器),其中每个项目(选项卡)都可以在用户关闭它时从 UI 中移除。但是,我不能直接从 ItemsControl.Items 中删除它。
这是一些 XAML data:FolderEntity 是一个 LINQ to SQL 数据类,它实现了 INotifyPropertyChanging 和 INotifyProperty
我有一个 Xamarin.Forms(3.2,最新版本)Picker实现为 BindingContext 是这个 ViewModel: public class ClassroomsViewMod
好吧,我正在设计一个自定义 WPF 控件——为了学习——它以类似于 Visual Studio 的方式显示日志消息。我想允许用户通过将消息实例添加到 Items 来添加消息集合,或通过绑定(bind)
我已经阅读了一些帖子,但没有人帮助我解决我的问题。 所以,我有一个带有 Viewmodel 的 View ,并且在 View 内部有一个 DataGrid 绑定(bind)到 viewmodel 内的
我有一个带有 ItemsSource 属性的 UserControl。由于基本的 UserControl 类没有实现 ItemsSource,我必须像这样创建自己的依赖属性: #region Item
在 WPF 中,您可以使用 IValueConverter 或 IMultiValueConverter 将数据绑定(bind)值从 int到 Color. 我有一个模型对象的集合,我想将它们转换为它
我有按钮“添加”和“删除”,但“删除”不起作用。怎么了? 算上我的ObservableCollection已更改,但 ListBox 未更改 示例项目:https://github.com/Vesel
我有一个 UniformGrid .在里面,我想放一个Grid其中包含 2 个 child - 和 Image和 Canvas .我已经有一个 List包含 Grid 的成员有了这个定义。 我正在更新
我是一名优秀的程序员,十分优秀!