First, check the effect.
Ideas:
Add a template column to the first column of each DataGrid, which defines only one textblock
In the row loading event of the DataGrid, add a number to the textblock of each row.
XAMLCode:
View code
< Data: DataGrid X: Name = "Gridlist" Grid. Row = "0" Margin = "5, 0, 5, 0" Gridlinesvisibility = "All"
Autogeneratecolumns = "False"
Frozencolumncount = "1"
Arerowdetailsfrozen = "True"
Horizontalalignment = "Stretch" Canusersortcolumns = "False"
Itemssource =" {Binding invstocklistmodellist, mode = twoway} "
Isreadonly = "True" Selecteditem =" {Binding invstocklistmodel, mode = twoway} " >
< Data: DataGrid. Columns >
< Data: datagridtemplatecolumn Header = "No" >
< Data: datagridtemplatecolumn. celltemplate >
< Datatemplate >
< Textblock />
</ Datatemplate >
</ Data: datagridtemplatecolumn. celltemplate >
</ Data: datagridtemplatecolumn >
< Data: datagridtextcolumn Header = "Item name" Binding =" {Binding materialmodel. mat_name, mode = twoway} " />
< Data: datagridtextcolumn Header = "Repository name" Binding =" {Binding storgemodel. storge_name, mode = twoway} " />
< Data: datagridtextcolumn Header = "Location name" Binding =" {Binding invlocationmodel. location_name, mode = twoway} " />
< Data: datagridtextcolumn Header = "Batch number" Binding =" {Binding stocklist_batch, mode = twoway} " />
< Data: datagridtextcolumn Header = "Year" Binding =" {Binding stocklist_year, mode = twoway} " />
< Data: datagridtextcolumn Header = "Accounting period" Binding =" {Binding stocklist_period, mode = twoway} " />
< Data: datagridtextcolumn Header = "Revenue amount" Binding =" {Binding stocklist_iamount, mode = twoway} " />
< Data: datagridtextcolumn Header = "Unit price" Binding =" {Binding stocklist_iprice, mode = twoway} " />
< Data: datagridtextcolumn Header = "Income amount" Binding =" {Binding stocklist_imoney, mode = twoway} " Width = "100" />
< Data: datagridtextcolumn Header = "Number of outgoing mails" Binding =" {Binding stocklist_oamount, mode = twoway} " />
< Data: datagridtextcolumn Header = "Unit price issued" Binding =" {Binding stocklist_oprice, mode = twoway} " />
< Data: datagridtextcolumn Header = "Amount issued" Binding =" {Binding stocklist_omoney, mode = twoway} " Width = "100" />
< Data: datagridtextcolumn Header = "End number" Binding =" {Binding stocklist_endamount, mode = twoway} " />
< Data: datagridtextcolumn Header = "End amount" Binding =" {Binding stocklist_endmoney, mode = twoway} " Width = "100" />
< Data: datagridtextcolumn Header = "Supplier batch number" Binding =" {Binding stocklist_suppbatch, mode = twoway} " />
</ Data: DataGrid. Columns >
</ Data: DataGrid >
CS code:
View code
Public Invstocklistview ()
{
Initializecomponent ();
Gridlist. loadingrow + = New Eventhandler < Datagridroweventargs > (Gridlist_loadingrow );
}
Void Gridlist_loadingrow ( Object Sender, datagridroweventargs E)
{
VaR Index = E. Row. getindex ();
VaR Cell = Gridlist. Columns [ 0 ]. Getcellcontent (E. Row) As Textblock;
If (Cell ! = Null ) Cell. Text = (Index + 1 ). Tostring ();
}
Success !!!
author: memories of lost youth
Source: http://www.cnblogs.com/lukun/
copyright of this Article It is shared by the author and the blog site. You are welcome to repost it, but this statement must be kept without the author's consent, and in the Article page obvious position to give the original connection, if there is a problem, you can contact me through the http://www.cnblogs.com/lukun/ , thank you very much.