In the enterprise application development process, we often have this demand: The program can calculate the tabular data, as far as possible to get the program to do, it is not difficult, it is difficult to try to improve the degree of human nature of the program, need to automatically calculate, that is, what is known as income.
In fact, this implementation is relatively simple, the main thing is to get the data of the currently selected row. The specific code is as follows:
XAML section:
<sdk:datagridtemplatecolumn header="Tax Income"> <sdk:DataGridTemplateColumn.CellTemplate> < ;D atatemplate> <textblock margin="2"Verticalalignment="Center"Horizontalalignment=" Left"text="{Binding NSSR}"Width=" -"/> </DataTemplate> </sdk:datagridtemplatecol Umn. Celltemplate> <sdk:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <textbox height=" -"Name="NSSR"text="{Binding PATH=NSSR, mode=twoway}"Width=" the"Textchanged="nssr_textchanged"></TextBox> </DataTemplate> </sdk:DataGridTemplateColumn.CellEditingTemplate> </sdk:datag Ridtemplatecolumn>
View Code
Background cs Section:
#regionChange in tax income valuePrivate voidNssr_textchanged (Objectsender, Textchangedeventargs e) {JXS_GSSR= This. Dg_sourcegssrxx.selecteditem asJxs_gssrxxinfo;//get information on a click lineTextBox AA= Sender asTextBox; if(Isnumber (AA. Text))//verifies whether the input is a number{Decimal bb= (aa. Text = =""?0: Convert.todecimal (aa. Text)); if(BB! =0) {Decimal temp= Convert.todecimal (JXS_GSSR.BBSR-BB)/BB; Jxs_gssr.bbccns= Math.Round (temp,3);//effect rendering, calculated in the BLL layer } } } #endregion
View Code
Relatively simple, just a simple study record.
Silverlight DataGrid Real-time computing