我正在尝试了解有关 ListView 的知识,现在我正在解决这个问题:我在后台代码中定义了一个列表视图。我想动态更改 gridviewcolumn celltemplate。例如通过使用复选框或按钮,或其他。甚至有可能吗?我的 ListView 的定义在这里: lvUsers.ItemsSource = LoadListViewData(); GridView gridview = new GridView(); lvUsers.View = gridview; DataTemplate templateCheck = new DataTemplate(); FrameworkElementFactory factoryContentControlCheck = new FrameworkElementFactory(typeof(VsCheckBox)); factoryContentControlCheck.SetValue(VsCheckBox.MarginProperty, new Thickness(0, 0, 0, 0)); DataTemplate templateBorder = new DataTemplate(); FrameworkElementFactory factoryContentControlBorder = new FrameworkElementFactory(typeof(Border)); factoryContentControlBorder.SetValue(Border.MarginProperty, new Thickness(0, 0, 10, 0)); factoryContentControlBorder.SetValue(Border.WidthProperty, Width = 10); factoryContentControlBorder.SetValue(Border.HeightProperty, Height = 10); factoryContentControlBorder.SetValue(Border.BackgroundProperty, Brushes.Red); DataTemplate templateAge = new DataTemplate(); FrameworkElementFactory factoryContentControlAge = new FrameworkElementFactory(typeof(ContentControl)); factoryContentControlName.SetValue(ContentControl.MarginProperty, new Thickness(0, 0, 10, 0)); factoryContentControlAge.SetValue(ContentControl.VerticalAlignmentProperty, VerticalAlignment.Center); factoryContentControlAge.SetValue(ContentControl.HorizontalAlignmentProperty, HorizontalAlignment.Right); factoryContentControlAge.SetBinding(ContentControl.ContentProperty, new Binding("Age"));我想在运行时通过选中复选框或按钮单击将 colStack 的 CellTemplate 更改为 templateStack1。
1 回答
- 1 回答
- 0 关注
- 394 浏览
添加回答
举报
0/150
提交
取消