Niu Ren does not enter Silverlight 4 DataGrid before add number

Source: Internet
Author: User

Recently, in the MIS Management System, you must add a sequence number and select all functions before the data list display (this articleArticleOnly solve the problem of adding the serial number in front of the DataGrid ).

My friends have explained some of the functions in this area. They all have the same functions and have nothing to say. The key lies in innovation. Today, I find another way to do this, maybe this is a kind of development

I would like to share my skills with you here. I hope this will help you in your future work.

Let's skip some basic work such as creating a project. Let's take a look at how to solve the problem. (This project is a demo under W7 theme)

Create a page and add a DataGrid Control to the page, as shown in:

Right-click the DataGrid to edit the current template:

In this case, we can see all the control objects in the current DataGrid template in the object and tiem window, as shown in:

If you want to know about the composition of a DataGrid, you may want to learn more about how it is made up;

Next, select the "topleftconterheader" template and modify its template, as shown in:

Add a textblock to its template, set its text to the serial number, and set its layout (set according to project requirements );

This step is almost done;

Next, modify an attribute in the DataGrid, as shown in:

Set headersvisibility to all;

 

Now let's write a model to provide data display for the IRD:

NamespaceSlw7theme. model {Public ClassStudent {Public StringName {Get;Set;}Public IntAge {Get;Set;}Public StringAddress {Get;Set;}}}

 

 

DataGrid Data Binding:

   Private   Void Getstudentlist () {var studnet = New List <model. Student> (); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address ="Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add (New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); studnet. Add ( New Model. Student () {name =" Caodaiming ", Address =" Sicuan ", Age = 24}); DG. itemssource = studnet ;}

 

Add a loadingrow event to the uploird. When adding a row, use the row index as the serial number;

 PublicDataGrid () {initializecomponent (); getstudentlist (); DG. loadingrow + =NewEventhandler <datagridroweventargs> (dg_loadingrow );}VoidDg_loadingrow (ObjectSender, datagridroweventargs e) {e. Row. header = E. Row. getindex () + 1 ;}

If pagination is added here, but the data after pagination is not accumulated here, you can use pagesize and pageindex for some work to implement a solution,

Do not solve it here;

At the end of the article, I found a problem. If all the DataGrid files in the project are in the same mode, you can modify the current template of the DataGrid. In this way, the current template is modified,

Pulling it from the tool later is the modified control. (modifying its copy template can also solve this problem, so there is a DataGrid style in the project );

My abilities are limited. If you have any mistakes, you are welcome to correct them. Learn and make progress together.

It's over.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.