ScrollIntoView In DataGrid In Silverlight 3 Application

No.of Views1312
Bookmarked0 times
Downloads 
Votes0
By  dpatra   On  16 Feb 2010 00:02:01
Tag : Silver Light and XAML , How to
ScrollIntoView In DataGrid In Silverlight 3 Application
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 Introduction
ScrollIntoView is a method available in DataGrid in Silverlight 3. This method provides the functionality to bring into view (display) a particular row or column in the DataGrid.
In this article we will see how we can use it.

Creating Silverlight Project
Fire up Blend 3 and create a Silverlight Application. Name it as ScrollIntoViewDataGridInSL3.


Image Loading.....


This is what we are going to do for our sample application: we will populate a DataGrid with sample data and search an item from the DataGrid. Go ahead and design with it in Expression Blend 3.

Image  Loading....

If you look into Object and Timeline Pane you will find the following hierarchy:

Image Loading.....

Add a class named Users.cs to define the properties of the sample data:

Image Loading.....

Add the following properties:

{codecitation class="brush: csharp; gutter: true;" width="700px"}

public class Users
{
public string Name { get; set; }
public int Age { get; set; }
public string Gender { get; set; }
public string Country { get; set; }
}



{/codecitation}

Now in MainPage.xaml.cs create sample data and assign the ItemSource as the List:

{codecitation class="brush: csharp; gutter: true;" width="700px"}

public MainPage()
{
InitializeComponent();
List myList = new List
{
new Users{ Name="Hiro Nakamura", Gender="M", Age=24, Country="Japan"},
new Users{ Name="Mohinder Suresh",Gender="M", Age=26, Country="India"},
new Users{ Name="Claire Bennette", Gender="F",Age=19, Country="USA"},
new Users{ Name="Matt Parkman", Gender="M",Age=30, Country="USA"},
new Users{ Name="Nathan Patrelli", Gender="M",Age=30, Country="USA"},
new Users{ Name="Peter Patrelli", Gender="M",Age=26, Country="USA"},
new Users{ Name="Mica", Age=12, Gender="M",Country="USA"},
new Users{ Name="Linderman", Gender="M",Age=56, Country="USA"},
new Users{ Name="Ando", Age=24, Gender="M",Country="Japan"},
new Users{ Name="Maya", Age=24, Gender="M",Country="Mexico"},
new Users{ Name="Niki Sanders", Gender="F",Age=26, Country="USA"},
new Users{ Name="Angela Patrelli", Gender="F",Age=26, Country="USA"},
};
MyDataGrid.ItemsSource = myList;
}



{/codecitation}

Now if you run your application you will get the DataGrid with sample data populated:

Image Loading.....

Thank you


About the Author


Diptimaya Patra

Description :I am a Master in Computer Application (MCA) from SRM University, Chennai. I am MCTS in ASP.Net Web Development, and MOSS 2007 Administration. I have extreme exposure to Microsoft Technologies in recent times like Silverlight 2, Silverlight 3. I am from Cuttack, Orissa. You can reach me using this mail (diptimaya.patra@gmail.com). Currently I am working as a Software Engineer in UST Global Inc in Trivandrum Center.

Occupation :Software Engineer
Company : UST Global.
Location : India
Follow me at twitter : http://twitter.com/dpatra


 
Sign Up to vote for this article
 
About Author
 
dpatra
Occupation-Not Provided
Company-Not Provided
Member Type-Expert
Location-Not Provided
Joined date-13 Jul 2009
Home Page-Not Provided
Blog Page-Not Provided
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top