views:

715

answers:

1

Hey, I've included an MS Access database in my WPF VB app, and I'm trying to link the data to an XCEED Datagrid. I have the following code in my testerDataSet.Designer.vb file which I assume is the funcion I should be referencing

Public ReadOnly Property Contact() As ContactDataTable
    Get
        Return Me.tableContact
    End Get
End Property

I'm trying to get it to fill my datagirid using this

 <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_contacts" Source="{Binding Path=Contact, *Source={x:Static testerDataSet}*}"/>
    </Grid.Resources>
    <xcdg:DataGridControl Margin="54,18,4,3" Name="DataGridControl1" ItemsSource="{Binding Source={StaticResource cvs_contacts}}"/>

Unfortunately the bolded/stared part is givi ng me errors, does anyone know the correct code i should be using here to reference my source?

Thanks guys!

EDIT: Okay let me try and outline what I've done... I've added an Access 2007 Database called "tester" to my project as an existing item, and VS has gone and made testerDataSet for me, and inside testerDataset.Designer.vb I assume the first code above is the code i need to display my table data.

Basically my entire code for Window1.xaml is as follows (its just a test project to see If I can actually get the database working)

<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="369" Width="503" xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"&gt;
<Grid>
    <Grid.Resources>
        <xcdg:DataGridCollectionViewSource x:Key="cvs_contacts" Source="{Binding Path=Contact, Source={StaticResource testerDataSet}}"/>
    </Grid.Resources>
    <xcdg:DataGridControl Margin="54,18,4,3" Name="DataGridControl1" ItemsSource="{Binding Source={StaticResource cvs_contacts}}"/>
</Grid>

What I'm trying to achieve is for the datagrid to display the data in the Contact datatable. I'm probably missing something important here (I'm quite new to coding =/ ) To be perfectly honest I've had a hard time finding appropriate tutorials for this so I'm not entirely sure what I'm doing

THanks again

A: 

Can you update your sample to include the code for the static resource testerDataSet?

One way you can try and work around this problem is to set the Binding directly in imperative code.

DataGridControl1.DataContext = testerDataSet.Contact

Then you could modify your WPF code to be the following

<xcdg:DataGridControl 
  Margin="54,18,4,3" 
  Name="DataGridControl1" 
  ItemsSource="{Binding}" />

That may not be 100% what you're looking for but it should at least temporarily unblock you.

JaredPar
Okies updated my first post. I tried your solution but it didn't work... I assume that's because I have no "code for the static resource testerDataSet?"?