tags:

views:

46

answers:

2

I'm trying to get a simple data grid working under WPF, and I have no idea why it's not working. Here is the XAML -

<Window x:Class="WpfApplication2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="333" Width="592">
    <Grid>
        <my:DataGrid AutoGenerateColumns="true" Margin="98,62,77,51" Name="dataGrid1" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"&gt;           
        </my:DataGrid>
    </Grid>
</Window>

And here is the constructor for the window -

 public Window1()
        {
            InitializeComponent();

            DataClasses1DataContext dc = new DataClasses1DataContext();            
            dataGrid1.DataContext = dc.Customers.ToList();

        }

DataClasses1 is just a Linq-2-SQL context mapping to the Northwind database. Can someone help?

A: 

Why you dont use datagrid1.DataSource = dc.Customers.ToList(); ?

afgallo
There is no DataSource attribute in the WPF data grid
CraigS
The property that you are looking for is called ItemsSource
Milan Nankov
+1  A: 

I think you have to use ItemsSource property of DataGrid.

dataGrid1.ItemsSource = dc.Customers.ToList(); 
Akash Kava
The XML namespaces are allowed to be put on any tag. They are usually put on the root node for convenience since they they only apply to the tag they are on, and any child nodes.
YotaXP
@YotaXP Thanks, i updated the answer, I thought namespace might be issue as his question was like whats wrong with xaml..
Akash Kava