当前位置: 首页 > news >正文

网站开发工具的功能包括html全国卫生计生机构建设管理系统网站

网站开发工具的功能包括html,全国卫生计生机构建设管理系统网站,济南品牌网站建设公司,做彩票网站违法的吗需求场景 列表类控件#xff0c;如 ListBox、ListView、DataGrid等。显示的行数据中#xff0c;部分内容依靠选中时触发控制#xff0c;例如选中行时行记录复选#xff0c;部分列内容控制显隐。 案例源码以ListView 为例。 Xaml 部分 ListView ItemsSource{Bi… 需求场景 列表类控件如 ListBox、ListView、DataGrid等。显示的行数据中部分内容依靠选中时触发控制例如选中行时行记录复选部分列内容控制显隐。 案例源码以ListView 为例。 Xaml 部分 ListView ItemsSource{Binding MyPropertys} IsManipulationEnabledFalseListView.ViewGridView!--该列用于自定义行逻辑--GridViewColumn Header操作列 GridViewColumn.CellTemplateDataTemplate!--该列用于自定义行逻辑--/DataTemplate/GridViewColumn.CellTemplate/GridViewColumnGridViewColumn Header内容列 DisplayMemberBinding{Binding MyProperty}/GridViewColumn Header内容列 DisplayMemberBinding{Binding MyProperty1}/GridViewColumn Header内容列 DisplayMemberBinding{Binding MyProperty2}/GridViewColumn Header内容列 DisplayMemberBinding{Binding MyProperty3}//GridView/ListView.View /ListViewViewModel部分 CaseItemViewModel作为数据项 public class CaseItemViewModel {public string MyProperty { get; set; }public string MyProperty1 { get; set; }public string MyProperty2 { get; set; }public string MyProperty3 { get; set; } }MainWindowViewModel作为上层ViewModel public class MainWindowViewModel {public ListCaseItemViewModel MyPropertys { get; set; }public MainWindowViewModel(){MyPropertys new ListCaseItemViewModel{new CaseItemViewModel { MyProperty 1, MyProperty1 1, MyProperty2 1, MyProperty3 1 },new CaseItemViewModel { MyProperty 2, MyProperty1 2, MyProperty2 2, MyProperty3 2 },new CaseItemViewModel { MyProperty 3, MyProperty1 3, MyProperty2 3, MyProperty3 3 },new CaseItemViewModel { MyProperty 4, MyProperty1 4, MyProperty2 4, MyProperty3 4 },new CaseItemViewModel { MyProperty 5, MyProperty1 5, MyProperty2 5, MyProperty3 5 }};} }设置MainWindowViewModel 到上层DataContext public partial class MainWindow : Window {public MainWindow(){InitializeComponent();// 设置上下文DataContext new MainWindowViewModel();} }分析思路 ItemsControl 的子类控件对应数据项多为xxxItem该控件继承关系如下 继承 [Object]–[DispatcherObject]–[DependencyObject]–[Visual]–[UIElement]–[FrameworkElement]–[Control]–[ContentControl]–[ListBoxItem] 派生 —[ComboBoxItem] —[ListViewItem] 排查 通过Vs2022自带工具查看对应的选中行页面对象。 选中行开启三项。 鼠标悬浮确认选择的是该元素节点。 点击转到实时可视化树定位元素。弹出实时可视化树窗口。 可以看到已经选中节点单击右键【显示属性】。 显示出对应的选中项实际UI元素当前属性。 其中属性关联项是ListBoxItem对应为IsSelected。是否可以考虑直接通过在数据模板中获取到UI 元素xxxItem的IsSelected 较少ViewModel 中添加额外属性。 public class ListViewItem : ListBoxItem {}public class ListBoxItem : ContentControl {public bool IsSelected { get; set; } }解决办法 方式一 如果是使用的MvvM架构设计可以为控件的子项ViewModel 添加 IsSelected属性从数据的维度去控制数据模板内的具体操作此处不展开细说主要以方式二为主。 public class CaseItemViewModel {// 省略重复项public bool IsSelected { get; set; } }方式二(推荐) 纯UI层级处理通过Binding 机制中提供的FindAncestor 方式直接获取上级 Item 控件项属性。好处是ViewModel中不需要再为了页面交互添加额外属性。 ListView ItemsSource{Binding MyPropertys} IsManipulationEnabledFalseListView.ViewGridView!--该列获取ListViewItem中的IsSelected属性--GridViewColumn Header操作列 GridViewColumn.CellTemplateDataTemplate!--使用Binding机制中的FindAncestor,查找到ListViewItem的IsSelected属性--CheckBox Content操作项 IsChecked{Binding IsSelected, RelativeSource{RelativeSource FindAncestor, AncestorType{x:Type ListViewItem}}} Foreground{Binding PathForeground, RelativeSource{RelativeSource FindAncestor, AncestorType{x:Type ListViewItem}}}/CheckBox/DataTemplate/GridViewColumn.CellTemplate/GridViewColumn!--省略重复内容--/GridView/ListView.View /ListView运行效果 非选中效果。 选中行效果。
http://www.eeditor.cn/news/118493/

相关文章:

  • 平顶山建设局网站做海报哪个网站好
  • 华为弹性云做网站天河区建网站
  • 局网站信息内容建设 自查报告做网站需要懂哪些语言
  • 网站开发项目总结中国建设监理协会继续教育网站
  • 在那个网站做推广实用上海网站搜索优化
  • 做网站ie10缓存保洁公司用哪些网站做推广
  • 山东建站管理系统网络安全工程师年薪
  • eclipes网站建设教程平面设计师赚钱吗
  • 网站建设的价格微分销平台登录
  • 西部数码 成品网站江西网站建设与推广
  • 佛山seo网站推广静态单页网站wordpress
  • 济南外贸网站建站查找网站备案
  • 购物小程序怎么做推广排名seo
  • 自己做网站怎么做长安高端装备网站设计公司
  • 网站开发制做好利来邢台官方网站开发部
  • 宿城网站建设建设网站思维导图
  • 平凉公司网站建设深圳宣传片制作排名前十名
  • 网站设计评价西安公司网站设计
  • 上海cms建站小程序定制开发解决方案
  • 仪征建设局招投标网站做网站优化排名
  • 营销网站的功能构成常州微网站建设
  • 住房与建设部网站 2018 128号网站建设与网页制作技术
  • 南山网站建设-信科网络word素材库
  • 内蒙古住房城乡建设部网站广告策划案例范文
  • cms开源框架资阳优化团队信息
  • html网站服务器搭建百度开发者大会
  • 网站建设公司 深圳信科南宁网站建设公司招聘
  • 公司网站 域名游戏开发公司招聘
  • 网站开发工具软件品牌设计作品集
  • 网站建设朱宁网站开发公司招聘