Unable to Bind to DataView objects

5 replies. Last post: January 2, 2013 3:03 AM by Yudi
Tags :
  • New Discussion
  • New Question
  • New Product Feedback

I am unable to get any Intersoft controls to Bind to a System.Data.DataView (IEnumerable) object

I have a local database (ms access) (could be any local db), and I use the VS10 IDE to bring in the datasets and setup the interface.  This creates DataTables and DataViews on which I can deal with the data.

I setup the MVVM ViewModel and unable to Bind anything to any Intersoft control.

Works great with other controls (non-intersoft)

According to the docs, as long as I got an IEnumerable, I should be able to get this to work, but no go!

Below is the ViewModel.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
namespace PostBooks.ViewModels {
    public class MainViewModel : ViewModelBase {
        private DataTable _bankAccounts;
        private dsPostBooks _dsPostBooks;
        private dsPostBooksTableAdapters.BankAccountsTableAdapter _taBankAccounts;
        private IEnumerable _items;
        public MainViewModel() {
            if (!DesignerProperties.GetIsInDesignMode(new DependencyObject())) { //no data error in design mode
                GetData();
                _items = _bankAccounts.DefaultView;
            }
        }
        public DataView BankAccounts {
            get { return _bankAccounts.DefaultView; }
            set {
                if (_bankAccounts.DefaultView != value) {
                    //_bankAccounts.DefaultView = value;
                    OnPropertyChanged("BankAccounts");
                }
            }
        }
        public IEnumerable Items {
            get { return _items; }
            set {
                if (_items != value) {
                    _items = value;
                    OnPropertyChanged("Items");
                }
            }
        }
        private void GetData() {
            _dsPostBooks = new dsPostBooks();
            _taBankAccounts = new dsPostBooksTableAdapters.BankAccountsTableAdapter();
            _taBankAccounts.Fill(_dsPostBooks.BankAccounts);
            _bankAccounts = _dsPostBooks.BankAccounts;
        }
    }
}
All times are GMT -5. The time now is 10:22 PM.
Previous Next