Silverlight dataGrid Simple Example:
Use the following Code.
Output:
xaml code:
Use the following code inside your xaml
<sdk:DataGrid AutoGenerateColumns="
True" Height="
201" HorizontalAlignment="
Left" Margin="
10,10,0,0" Name="
dataGrid1" VerticalAlignment="
Top" Width="
167" />
C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
namespace samp
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
loaddata();
}
private void loaddata()
{
List<Data> lobj = new List<Data>();
lobj.Add(new Data() {UserID="0001"});
lobj.Add(new Data() { UserID = "0001" });
lobj.Add(new Data() { UserID = "0001" });
lobj.Add(new Data() { UserID = "0001" });
dataGrid1.ItemsSource = lobj;
}
}
public class Data
{
public string UserID { get; set; }
}
}
Comments
Post a Comment