(WPF) DataGrid之绑定
通过ObservableCollection 绑定到 DataGrid.
1. 前台Xaml.
<DataGrid x:Name="dgMeasurements"
HorizontalAlignment="Left"
Margin="10,69,0,10"
ItemsSource="{Binding}"
AutoGenerateColumns="False"
Width="">
<DataGrid.Columns>
<DataGridTextColumn Header="Name"
Width=""
Binding="{Binding Name}" />
<DataGridTextColumn Header="Unit"
Width=""
Binding="{Binding Unit}" />
<DataGridTextColumn Header="Value"
Width=""
Binding="{Binding Value}" />
<DataGridTextColumn Header="LowerLimit"
Width=""
Binding="{Binding LowerLimit}" />
<DataGridTextColumn Header="UpperLimit"
Width=""
Binding="{Binding UpperLimit}" />
</DataGrid.Columns> </DataGrid>
2. 后台Code
ObservableCollection 如果是Struct的话,则不能正确的显示。原因未知,有空仔细研究一下。
参考: http://www.cnblogs.com/gnielee/archive/2010/04/16/wpf4-datagrid-control-basic.html
ObservableCollection<TestMeasurements> measurements = new ObservableCollection<TestMeasurements>();
//measurements.Add(new TestMeasurements()...
dgMeasurements.DataContext = measurements;
(WPF) DataGrid之绑定的更多相关文章
- WPF DataGrid foreground 绑定问题
初学WPF , 希望对DataGrid 中所属的一个Column名下的值的颜色动态修改 <DataGridTextColumn Header="隐含回购利率(%)" Bin ...
- WPF DataGrid某列使用多绑定后该列排序失效,列上加入 SortMemberPath 设置即可.
WPF DataGrid某列使用多绑定后该列排序失效 2011-07-14 10:59hdongq | 浏览 1031 次 悬赏:20 在wpf的datagrid中某一列使用了多绑定,但是该列排序失 ...
- WPF DataGrid绑定一个组合列
WPF DataGrid绑定一个组合列 前台: <Page.Resources> <local:InfoConverter x:Key="converter& ...
- WPF DataGrid 绑定行双击行命令
WPF DataGrid 绑定行双击行命令 <DataGrid ...> <DataGrid.InputBindings> <MouseBinding MouseActi ...
- WPF dataGrid下的ComboBox的绑定
WPF dataGrid下的ComboBox的绑定 Wpf中dataGrid中的某列是comboBox解决这个问题费了不少时间,不废话了直接上代码 xaml 代码 <DataGridTempla ...
- WPF DataGrid 双击行 获得绑定数据
原文:WPF DataGrid 双击行 获得绑定数据 1)增加事件 2)增加对象获取 1)事件代码 Datagrid 增加事件 MouseDoubleClick="dataGrid_Mous ...
- WPF Datagrid 动态生成列 并绑定数据
原文:WPF Datagrid 动态生成列 并绑定数据 说的是这里 因为列头是动态加载的 (后台for循环 一会能看到代码) 数据来源于左侧列 左侧列数据源 当然num1 属于临时的dome使用 可 ...
- WPF DataGrid 绑定数据及时更新的处理
原文:WPF DataGrid 绑定数据及时更新的处理 默认情况下datagrid 绑定数据源后,在界面编辑某一列后,数据不会及时更新到内存对象中.如在同一行上有一个命令对来获取 当前选中行(内存对象 ...
- WPF DATAGrid 空白列 后台绑定列 处理
原文:WPF DATAGrid 空白列 后台绑定列 处理 AutoGenerateColumns <DataGrid x:Name="dataGrid" Margin=&qu ...
随机推荐
- MySQL数据查询结果导出生成文件
select url from news where url like "%美女%" into outfile "/导出的文件路径" : 在这里有个坑,对于 ...
- 如何进bat
既然是要谈如何进入BAT,那么咱们就从面试的角度来谈学习这件事,会谈谈一流互联网公司对于Java后端程序员的要求,相应的,也会谈谈如何达到这样的要求. 为了简单起见,这些要求分为三个层次,分别为基本要 ...
- Unity 动画系统 StateMachineBehaviour 动画状态机
- elasticsearch 相关命令
ubuntu server 启动命令:$ ./bin/elasticsearch 后台运行:$ ./bin/elasticsearch -d 查看当前进程:$ jps 启动后检查是否成功命令:$ cu ...
- sharepoint_study_9
描述:sharepoint2013 网站修改导航条标题 SuiteBartext 图示: 解决: 管理员身份进sharepoint powershell ,依次敲入搞定1. $app = Get-SP ...
- lintcode - 统计比给定整数小的数的个数(两种方法)
class Solution { public: /* * @param A: An integer array * @param queries: The query list * @return: ...
- jq ajax超时设置
var ajaxTimeoutTest = $.ajax({ url:'', //请求的URL timeout : 1000, //超时时间设置,单位毫秒 type : 'get', //请求方式,g ...
- getter与setter
var obj = { get a() { return 2; }, get c() { return 34 } } Object.defineProperty( obj, 'b', { get: f ...
- 自定义element-ui主题
自定义element主题颜色:主要参考这个文章https://blog.csdn.net/wangcuiling_123/article/details/78513245,再自己做了一遍成功.感谢. ...
- css连续的纯数字或字母强制换行
white-space:normal; word-break:break-all; white-space: normal|pre|nowrap|pre-wrap|pre-line|inherit;w ...