首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏个人编程笔记

    C#-DataGrid的使用(三)

    上,下面是参考代码: //datagrid.xaml <DataGrid.Resource> <Style TargetType="<em>DataGridRow</em>"> <Setter "></EventSetter> <EventSetter Property="PreviewMouseLeftButtonDown" Handle="<em>DataGridRow</em>_Drop" ></EventSetter> </Style> </DataGrid.Resource> //datagrid.xaml.cs private DataGridRow _draggedItem e){ //记录鼠标开始的位置 _startPoint=e.GetPosition(this); } private void DataGridRow_PreviewMouseMove (object sender,DragEventArgs e){ try{ if(sender is DataGridRow){ DataGridRow

    43410编辑于 2023-10-17
  • 来自专栏个人编程笔记

    C#-DataGrid的使用(三)

    之前我们是在鼠标移动的时候,如果左键按下,直接进入拖拽状态中,这就导致行中按钮的点击没办法执行,所以我们加一个判断,让鼠标移动一定的距离之后进入拖拽状态,可以避免此问题,另外,我们这里把鼠标事件写到datagridrow 上,下面是参考代码://datagrid.xaml<DataGrid.Resource> <Style TargetType="<em>DataGridRow</em>"> <Setter Property "></EventSetter> <EventSetter Property="PreviewMouseLeftButtonDown" Handle="<em>DataGridRow</em>_Drop"> </EventSetter> </Style></DataGrid.Resource>//datagrid.xaml.csprivate DataGridRow _draggedItem;private (object sender,DragEventArgs e){ try{ if(sender is DataGridRow){ DataGridRow targetRow

    35620编辑于 2023-06-20
  • 来自专栏hbbliyong

    WPF备忘录(3)如何从 Datagrid 中获得单元格的内容与 使用值转换器进行绑定数据的转换IValueConverter

    在DataGrid的Items集合中,DataGridRow 是一个Item,但是,它里面的单元格却是被封装在 DataGridCellsPresenter 的容器中;因此,我们不能使用 像DataGridView.Rows.Cells 但是,在WPF中我们可以通过可视树(VisualTree) 去进入到控件“内部“, 那么,我们当然可以通过VisualTree进入DataGrid中的DataGridRow 和 DataGridCellsPresenter , 并且得到在DataGridCellsPresenter中的实例, 大家可以通过以下的代码遍历VisualTree DataGridRow rowContainer = (DataGridRow)dataGrid1

    7.5K70发布于 2018-03-05
  • 来自专栏Windows Community

    Windows Community Toolkit 4.0 - DataGrid - Part03

    public DataGrid() { this.TabNavigation = KeyboardNavigationMode.Once; _loadedRows = new List<DataGridRow DataGridCellEditEndedEventArgs : EventArgs { public DataGridCellEditEndedEventArgs(DataGridColumn column, DataGridRow public DataGridEditAction EditAction { get; private set; } public DataGridRow internal class DataGridCellCollection { private List<DataGridCell> _cells; private DataGridRow internal event EventHandler<DataGridCellEventArgs> CellRemoved; public DataGridCellCollection(DataGridRow

    82020发布于 2018-10-10
  • 来自专栏个人编程笔记

    C#-DataGrid

    IsEnabled}"></Setter> </Style> </DataGridTextColumn.CellStyle> 删除选中的行,支持多选 在Model中添加属性IsSelected,将其绑定到DataGridRow <DataGrid.Resources> <Style TargetType="<em>DataGridRow</em>"> <Setter Property="IsSelected" Value

    1K20编辑于 2023-03-18
  • 来自专栏个人编程笔记

    C#-datagrid使用

    DataGrid ItemsSource="{Binding TableColorModels}"> <DataGrid.RowStyle > <Style TargetType="<em>DataGridRow</em> Binding TableColorModels}"> <DataGrid.RowStyle > <Style TargetType="<em>DataGridRow</em> as DataGrid; //if (dataGrid.BeginEdit()) return; _preRow = FindVisualParent<<em>DataGridRow</em> return null; } private void dataGrid_Drop(object sender, DragEventArgs e) { try { <em>DataGridRow</em> dr = FindVisualParent<<em>DataGridRow</em>>(e.OriginalSource as FrameworkElement); if (dr !

    1.3K00编辑于 2023-03-03
  • 来自专栏Windows Community

    Windows Community Toolkit 4.0 - DataGrid - Overview

    我们可以先看一遍这里类的大致作用,后面会详细讲解每个类的代码实现: Automation - DataGrid UIA 实现 DataGrid,DataGridColumn,DataGridRow,DataGridCell 控件类,控件头,基于这些类的实现类; DataGrid,DataGridColumn,DataGridRow,DataGridCell 相关事件处理类; DataGrid,DataGridColumn ,DataGridRow,DataGridCell 相关数据类; ?

    1.3K20发布于 2018-08-27
  • 来自专栏web全栈之路

    #region 判断datagrid是否点击的数据行

    = null && i < 10000)             {                 if (target is System.Windows.Controls.DataGridRow

    68620编辑于 2022-09-29
  • 来自专栏哲学驱动设计

    OEA 中 WPF 树型表格虚拟化设计方案

        结合上面这个图,再查阅 DataGrid 源码,可以看出:     * 整个 DataGrid 表格中只有一个 ScrollViewer,表格作为一个 ItemsControl,内部每一项是一个 DataGridRow 继承自 VirtualizingStackPanel,就间接继承 VirtualizingPanel 并实现 IScrollInfo 接口,为最外层的 ScrollViewer 提供滚动信息,提供 DataGridRow * 每一个 DataGridRow 中,使用一个继承自 ItemsControl 的 DataGridCellsPresenter 来生成每一个单元格的容器,而它则使用 DataGridCellsPanel * 另外,需要额外说明下两个 ItemsControl 的数据源:DataGrid 的 ItemsSource 当然就是应用层指定的数据模型的列表,这样,每一个 DataGridRow 的 DataContext DataContext,也应该是每一个单元格的 DataContext,所以 DataGridCellsPresenter.ItemsSource 应该被设置为一个数据模型对象列表,其中每一个元素都是 DataGridRow.DataContext

    3.7K70发布于 2018-01-29
  • 来自专栏dotNET编程大全

    C# WPF DataGrid获取单元格并改变背景色

    当前选择的行是:" + i.ToString()); rowindex = i; } } DataGridRow row = (DataGridRow)dgSourceData.ItemContainerGenerator.ContainerFromIndex(rowindex);//获取选中单元格所在行

    3.6K20编辑于 2022-01-13
  • 来自专栏独立观察员博客

    WPF DataGrid 如何将被选中行带到视野中

    中附加行为的介绍 Introduction to Attached Behaviors in WPF》文章中的将 TreeViewItem(树状列表项)带到视野中的方法,我稍微改造了一下,使其同时支持 DataGridRow bool == false) return; switch (depObj) { case DataGridRow

    2.8K10编辑于 2022-12-06
  • 来自专栏Niuery的技术日记

    WPF --- 重写圆角DataGrid样式

    Template="{Binding ValidationErrorTemplate, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow Converter={StaticResource bool2VisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow Setter.Value> </Setter> </Style> <Style x:Key="DefaultDataGridRowStyle" TargetType="{x:Type <em>DataGridRow</em> Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type <em>DataGridRow</em>

    1.4K20编辑于 2023-10-22
  • 来自专栏dino.c的专栏

    [WPF 自定义控件]创建包含CheckBox的ListBoxItem

    CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow

    4K20发布于 2020-02-21
  • 来自专栏开心的平凡酱

    动态生成RDLC报表

    rowIndex < dataGrid.Items.Count; rowIndex++) { // 要显示后,才能取到数据 DataGridRow rowContainer = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex); // 因为Peformance问题,EnableRowVirtualization被设置为true,只加载要显示的数据 // 重新滚动,然后再重用这些DataGridRow dataGrid.ScrollIntoView(dataGrid.Items[rowIndex]); rowContainer = (DataGridRow

    9.8K50发布于 2020-10-09
  • 来自专栏DotNet程序园

    【翻译】.NET Core3.1发布

    建议使用以下替代产品: 旧控件(API) 建议更换 其他关联的API已删除 DataGrid DataGridView DataGridCell,DataGridRow,DataGridTableCollection

    2.1K40发布于 2019-12-17
  • 来自专栏HueiFeng技术专栏

    【翻译】.NET Core3.1发布

    建议使用以下替代产品: 旧控件(API) 建议更换 其他关联的API已删除 DataGrid DataGridView DataGridCell,DataGridRow,DataGridTableCollection

    2K10发布于 2020-01-22
  • 来自专栏Kiba518

    C#语法——事件,逐渐边缘化的大哥。

    比如,当控件DataGrid的事件被触发时,只要查看一下sender的真实类型,就可以知道,到底是DataGrid触发的事件,还是DataGridRow或DataGridCell触发的了。

    2.4K30发布于 2018-08-23
  • 来自专栏历史专栏

    【愚公系列】2023年10月 WPF控件专题 DataGrid控件详解

    UserList}" > <DataGrid.RowStyle> <Style TargetType="<em>DataGridRow</em>

    5.3K00编辑于 2023-10-12
  • 来自专栏历史专栏

    【愚公系列】2023年04月 WPF运动控制平台-005.运动平台之功能实现(完结)

    Property="Height" Value="30" /> </Style> <Style x:Key="DataRowStyle" TargetType="{x:Type <em>DataGridRow</em>

    67820编辑于 2023-04-28
领券