This project has moved and is read-only. For the latest updates, please go here.

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.

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

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