How can I bind DataSource property in xaml?

Mar 23, 2011 at 2:42 PM

I need to bind in xaml the DataSource property of a BindableDataGrid to a DataTable that I'm building in my ViewModel. I'm getting a System.ArgumentException that says: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'BindableDataGrid.Data.IDataSource'.

Does anybody have an example using bindableDataGrid in a mvvm application? I've tried this but it gives the mentioned exception. MyDataTable is DataTable type.

   <UserControl.Resources>
      <CollectionViewSource x:Key="editTableViewModelViewSource" d:DesignSource="{d:DesignInstance my:EditTableViewModel, CreateList=True}" />
      <CollectionViewSource x:Key="editTableViewModelModelViewSource" Source="{Binding Path=Model, Source={StaticResource editTableViewModelViewSource}}" />
   </UserControl.Resources>

   <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource editTableViewModelModelViewSource}">
      <Grid.RowDefinitions>
         <RowDefinition Height="80" />
         <RowDefinition />
         <RowDefinition Height="40" />
      </Grid.RowDefinitions>
      <bDG:BindableDataGrid 
         x:Name="modelDataGrid" 
         AutoGenerateColumns="True"  Width="640" Height="400" 
         DataSource="{Binding Path=CurrentItem.MyDataTable, Source={StaticResource editTableViewModelViewSource}}"
       />