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

西安cms模板建站新网站如何快速收录

西安cms模板建站,新网站如何快速收录,便宜的在线客服系统,博客页面html模板本教程讲解了如何添加GridControl到wpf项目中并且绑定数据 原文地址Lesson 1 - Add a GridControl to a Project and Bind it to Data | WPF Controls | DevExpress Documentation 1、使用 DevExpress Template Gallery创建一个新的空白mvvm应用程序,这个项目包括了…

本教程讲解了如何添加GridControl到wpf项目中并且绑定数据

原文地址Lesson 1 - Add a GridControl to a Project and Bind it to Data | WPF Controls | DevExpress Documentation

1、使用 DevExpress Template Gallery创建一个新的空白mvvm应用程序,这个项目包括了一个视图模型,设置此视图模型作为MainView数据上下文

2、按照如下给此项目添加数据库Blank .NET 6 App with the Northwind Database .

3、在MainView中添加工具箱选项GridControl:

如果你的项目没有DevExpress.Wpf.Grid.Core 引用,vs一定显示如下信息:

此消息提示你必须添加控件引用。

如果你从Nuget订阅devexpress,进入工具,nuget包管理器,添加DevExpress.Wpf.Grid

4、在Quick Actions菜单中选择GridControl,点击绑定到数据源,在Items Source Wizard:

5、选择数据源:

在GridControl选择table:

选择简单绑定模型,查看如下提示消息关于绑定模型:WPF Data Grid: Bind to Data.

确保CRUD 选项启动:

在视图模型选择视图模型选项生成数据绑定源码。在已选择的View Model中选择MainViewModel:

6、Items Source Wizard 生成如下代码:

<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" ItemsSource="{Binding ItemsSource}" RestoreStateKeyFieldName="OrderId" RestoreStateOnSourceChange="True"><dxg:GridControl.TotalSummary><dxg:GridSummaryItem Alignment="Right" SummaryType="Count"/></dxg:GridControl.TotalSummary><dxg:GridControl.InputBindings><KeyBinding Command="{Binding View.Commands.DeleteFocusedRow, ElementName=grid}" Key="Delete"/></dxg:GridControl.InputBindings><dxg:GridControl.View><dxg:TableView NewItemRowPosition="Top" ShowUpdateRowButtons="OnCellEditorOpen" ValidateRowCommand="{Binding ValidateRowCommand}" ValidateRowDeletionCommand="{Binding ValidateRowDeletionCommand}" DataSourceRefreshCommand="{Binding DataSourceRefreshCommand}" ShowFixedTotalSummary="True"/></dxg:GridControl.View><dxg:GridColumn FieldName="OrderId" IsSmart="True" ReadOnly="True"/><dxg:GridColumn FieldName="CustomerId" IsSmart="True"/><dxg:GridColumn FieldName="EmployeeId" IsSmart="True"/><dxg:GridColumn FieldName="OrderDate" IsSmart="True"/><dxg:GridColumn FieldName="RequiredDate" IsSmart="True"/><dxg:GridColumn FieldName="ShippedDate" IsSmart="True"/><dxg:GridColumn FieldName="ShipVia" IsSmart="True"/><dxg:GridColumn FieldName="Freight" IsSmart="True"/><dxg:GridColumn FieldName="ShipName" IsSmart="True"/><dxg:GridColumn FieldName="ShipAddress" IsSmart="True"/><dxg:GridColumn FieldName="ShipCity" IsSmart="True"/><dxg:GridColumn FieldName="ShipRegion" IsSmart="True"/><dxg:GridColumn FieldName="ShipPostalCode" IsSmart="True"/><dxg:GridColumn FieldName="ShipCountry" IsSmart="True"/>
</dxg:GridControl>
using DevExpress.Mvvm;
using System;
using WPF_DataGrid_GetStarted.Models;
using DevExpress.Mvvm.DataAnnotations;
using System.Linq;
using System.Collections.Generic;
using DevExpress.Mvvm.Xpf;namespace WPF_DataGrid_GetStarted.ViewModels {public class MainViewModel : ViewModelBase {NorthwindEntities _Context;IList<Order> _ItemsSource;public IList<Order> ItemsSource {get {if (_ItemsSource == null && !DevExpress.Mvvm.ViewModelBase.IsInDesignMode) {_Context = new NorthwindEntities();_ItemsSource = _Context.Orders.ToList();}return _ItemsSource;}}[Command]public void ValidateRow(RowValidationArgs args) {var item = (Order)args.Item;if (args.IsNewItem)_Context.Orders.Add(item);_Context.SaveChanges();}[Command]public void ValidateRowDeletion(ValidateRowDeletionArgs args) {var item = (Order)args.Items.Single();_Context.Orders.Remove(item);_Context.SaveChanges();}[Command]public void DataSourceRefresh(DataSourceRefreshArgs args) {_ItemsSource = null;_Context = null;RaisePropertyChanged(nameof(ItemsSource));}}
}

这个代码启动CRUD operations ,为每一个数据源字段生成行,然后显示所有行数在fixed summary panel.

7、运行如下:

http://www.shuangfujiaoyu.com/news/2292.html

相关文章:

  • 把网站做静态化市场推广方案和思路
  • 网站添加内容电商平台怎么做
  • 天津住房与城乡建设厅网站百度网站排名查询
  • 如何把做的网站与域名连接不上windows优化大师官方
  • 招工网站怎么做河源seo
  • 网站的照片上传的功能怎么做软件培训班学费多少
  • 卡地亚手表官方网站网推项目平台
  • 新素材网站深圳推广网络
  • 卖鞋的网站建设思路杭州seo技术培训
  • 网站社区的建设东莞做网站的公司有哪些
  • 政务公开政府网站建设管理如何做电商新手入门
  • 网站建设有几种方式广告推广文案
  • 中国住房和城乡建设部网站6网站关键词排名如何提升
  • 网络推广工作任务福州seo视频
  • 白石洲附近做网站公司pc优化工具
  • 南宁网站建设费用东莞网站排名推广
  • 企业网站设计建设服务强强seo博客
  • wordpress图片特效抖音seo什么意思
  • 广告电商怎么做郑州seo
  • 天眼免费查询个人淄博搜索引擎优化
  • 高端网站设计定制公司营销方式和渠道
  • 做网站一定要用ps吗危机公关处理
  • 长治建一个网站大概要多少钱长沙seo网站排名优化公司
  • b2b网站想申请支付宝借口适合35岁女人的培训班
  • 手机微信客户端网站建设游戏推广代理
  • 做国际网站seo搜索优化工程师招聘
  • 7 the wordpress潍坊网站建设优化
  • 网站改版怎么做搜索引擎网络排名
  • layui响应式网站开发教程适合成人参加的培训班
  • 湛江网站建设方案维护如何做好网络宣传工作