如何在运行时在datagridtextcolumn中输入数据。并在datagrid的末尾添加新行以获取新数据......? [英] How to enter data in datagridtextcolumn at runtime. And add new row at the end of datagrid for new data...?

查看:85
本文介绍了如何在运行时在datagridtextcolumn中输入数据。并在datagrid的末尾添加新行以获取新数据......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< datagrid name =itemGridgrid.row =5grid.column =0grid.columnspan =4autogeneratecolumns =Falsemargin =0,25,0,5grid。 rowspan =2canuserreordercolumns =Falsecanuserresizecolumns =Falsecanusersortcolumns =Falseselectionunit =Cellcanuserresizerows =False>



< datagrid.columns>



< datagridtextcolumn header =Sr No. width =50>

< datagridtemplatecolumn header =Itemwidth =300>

< datagridtemplatecolumn.celltemplate>

< datatemplate>

< local:filteredcombobox x:name =FilteredComboBox1itemssource ={Binding}itemspanel ={DynamicResource ItemsTemplate}xmlns:x =#unknownxmlns :local =#unknown>







< datagridtextcolumn header =Quantitywidth =100>

< datagridtextcolumn header =单价width =100>

< datagridtextcolumn header =Vat%width = 100>

< datagridtext column header =Discountwidth =100>

< datagridtextcolumn header =Sub-Totalwidth =170>



< comboboxitem>


<datagrid name="itemGrid" grid.row="5" grid.column="0" grid.columnspan="4" autogeneratecolumns="False" margin="0,25,0,5" grid.rowspan="2" canuserreordercolumns="False" canuserresizecolumns="False" canusersortcolumns="False" selectionunit="Cell" canuserresizerows="False">

<datagrid.columns>

<datagridtextcolumn header="Sr No." width="50">
<datagridtemplatecolumn header="Item" width="300">
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<local:filteredcombobox x:name="FilteredComboBox1" itemssource="{Binding}" itemspanel="{DynamicResource ItemsTemplate}" xmlns:x="#unknown" xmlns:local="#unknown">



<datagridtextcolumn header="Quantity" width="100">
<datagridtextcolumn header="Unit Price" width="100">
<datagridtextcolumn header="Vat %" width="100">
<datagridtextcolumn header="Discount" width="100">
<datagridtextcolumn header="Sub-Total" width="170">

<comboboxitem>

推荐答案

如果您正在使用MVVM那么。



1.使用I notifyPropertyvchanged界面在每个类上使用observablecollection< model>

2.绑定您的集合,以添加和更新模型。 />
3.每次在集合中添加项目时,它都会更新UI。
If you are using MVVM then.

1. Bind your collection with the observablecollection <model>
2. on the each class using the I notifyPropertyvchanged interface to add and update the model.
3. Every Time you add a item into the collection it will update the UI.


这篇关于如何在运行时在datagridtextcolumn中输入数据。并在datagrid的末尾添加新行以获取新数据......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆