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

网站的外部链接建设图片什么网站会更有浏览量

网站的外部链接建设图片,什么网站会更有浏览量,wordpress房产主题汉化版,网站开发的问题有哪些需求场景 列表类控件&#xff0c;如 ListBox、ListView、DataGrid等。显示的行数据中&#xff0c;部分内容依靠选中时触发控制&#xff0c;例如选中行时行记录复选&#xff0c;部分列内容控制显隐。 案例源码以ListView 为例。 Xaml 部分 <ListView ItemsSource"{Bi…

blog-hbh-hc-header

需求场景

列表类控件,如 ListBox、ListView、DataGrid等。显示的行数据中,部分内容依靠选中时触发控制,例如选中行时行记录复选,部分列内容控制显隐。
案例源码以ListView 为例。

Xaml 部分

<ListView ItemsSource="{Binding MyPropertys}" IsManipulationEnabled="False"><ListView.View><GridView><!--该列用于自定义行逻辑--><GridViewColumn Header="操作列" ><GridViewColumn.CellTemplate><DataTemplate><!--该列用于自定义行逻辑--></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><GridViewColumn Header="内容列" DisplayMemberBinding="{Binding MyProperty}"/><GridViewColumn Header="内容列" DisplayMemberBinding="{Binding MyProperty1}"/><GridViewColumn Header="内容列" DisplayMemberBinding="{Binding MyProperty2}"/><GridViewColumn Header="内容列" DisplayMemberBinding="{Binding MyProperty3}"/></GridView></ListView.View>
</ListView>

ViewModel部分

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 List<CaseItemViewModel> MyPropertys { get; set; }public MainWindowViewModel(){MyPropertys = new List<CaseItemViewModel>{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 元素xxxItemIsSelected 较少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}" IsManipulationEnabled="False"><ListView.View><GridView><!--该列获取ListViewItem中的IsSelected属性--><GridViewColumn Header="操作列" ><GridViewColumn.CellTemplate><DataTemplate><!--使用Binding机制中的FindAncestor,查找到ListViewItem的IsSelected属性--><CheckBox Content="操作项" IsChecked="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"></CheckBox></DataTemplate></GridViewColumn.CellTemplate></GridViewColumn><!--省略重复内容--></GridView></ListView.View>
</ListView>
运行效果

非选中效果。

选中行效果。

http://www.yayakq.cn/news/464756/

相关文章:

  • 采集网站后台数据朝阳网站开发
  • 公司网站开发国内外现状海外域名平台
  • php简易购物网站开发企业信息平台登录
  • 淄博百度网站中山企业建站程序
  • 建设部网站申请表无法打印wordpress importer 0.6.1
  • 厦门网站专业建设什么叫网页版微信
  • 广平专业做网站图片网站php源码
  • 网站的兼容性搭建WordPress教程
  • 网站建设属于资产南京网络科技公司
  • 图片类网站欣赏怎么用dw做博客网站
  • 如何用万网做自己的网站建设彩票网站
  • 仿懒人图库网站源码地方门户网站如何盈利
  • 成都快速建网站怎么建设网站数据库
  • 济南网站建设开发手机网站如何做
  • 量化交易网站开发python做项目的网站
  • 做交互网站南京建设交易中心网站
  • 霸州市网站建设郑州电力高等专科学校宿舍
  • 个人网页设计论文范文安卓aso优化工具
  • 免费招聘网站有哪些平台动漫设计师工资一般多少
  • 网站前期基础建设 怎么写网站代做多少钱
  • 青岛集团网站建设用dw做的网站
  • 文化传播公司网站备案内容营销和传统营销的区别
  • 万网做网站花多少钱长春企业网站制作优化
  • 网站建设 天佩营销注册公司流程和费用联系人不一样
  • 上海市建设工程 安全质量网站wordpress修改描述
  • 新浪微博可以做网站吗飓风seo刷排名软件
  • 西宁高端网站制作公司做音乐网站的选题背景
  • 微信微网站统计公众号会员卡管理系统
  • wordpress怎么自动手机版谷歌搜索优化
  • 自适应网站建设专家江西专业的企业网站建设公司