Wednesday, January 10, 2007

How to make simple (Free!) Grid in WPF with XAML from DataSet or DataTable

This is just a concept you can start with to make your own Grid in XAML.

XAML Part:

<ListBox x:Name="tgData"
ItemsSource="{Binding Path=TableOne}"
Style="{DynamicResource HorizontalList}"
ItemsSource="{Binding Path=Row.ItemArray}"
<TextBlock Width="100" Text="{Binding}" />

XAML Style for Horizontal List for columns:
<Style x:Key="HorizontalList" TargetType="{x:Type ListBox}">
<Setter Property="Template">
<StackPanel Orientation="Horizontal" Panel.IsItemsHost= "True"/>

Code Behind (VB.Net):
Dim sConnectionString As String = "Data Source=Kelner;Database=Northwind;Integrated Security=SSPI;"
Dim sQueryString As String = "SELECT * FROM dbo.Customers"

Dim dsCustomer As New DataSet("CustomerData")
Dim conn As SqlClient.SqlConnection = New SqlClient.SqlConnection(sConnectionString)
Dim adapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(sQueryString, conn)

Dim customers As DataSet = New DataSet
adapter.Fill(dsCustomer, "TableOne")
tgData.DataContext = dsCustomer


1 comment:

bansal tirkey said...

We have a List of Girls who are in financial problems.Call Girls whatsapp number in Agra They need your help. They are ready to sleep with you in some small amounts.Call Girls whatsapp number in Agra Call us for their contact no and help them.Call Girls whatsapp number in Ahmedabad To book an escort just drop a call to the given number and ask them what kind of service you want!.Call Girls whatsapp number in Haridwar You will also WhatsApp us for the availability of our Escorts contact number in Aerocity . If you’re in the end determined and ready to enjoy the amusing of being at duration the corporate of one of our beautiful girls.Call Girls whatsapp number in Delhi Check our other Services...