iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
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; } } }
Thank you for your recent inquiry regarding binding Intersoft ClientUI controls to IEnumerable object.
I created a simple sample of UXGridView bind to collection of customers based on your description. The Customers’s data is obtained from Customers table of Northwind.mdb (MS Access database).
The project is enclosed as attachment. Please have the project tested on your end and let us hear your feedback whether this helps or not.
PS: before run/build the sample project, please open CustsViewModel.cs file and set the OleDbConnection to the correct path
Yudi,
I have your cust example working just fine. Yes, Intersoft controls work great with ObservableCollection. That is NOT the problem.
I have a DataView object, which is also IEnumerable and works fine with other control bindings, just not intersoft. WHY WHY WHY?? According to the documentation, if its IEnumerable, it should work, BUT it does NOT work. WHY?
I am using an Access Db as local db. I am using Visual Studio Data Source Designer to bring in all the data model and hibernate all the needed interface. Why would I want to manually create all my data models using ModelBase.cs and create all new ViewModel functions using ObservableCollection???
This would take a lot of time and effort. Yes!!!
The problem remains, Intersoft does NOT bind to DataView or CollectionViewSource objects. Most everything on the PLANT EARTH DOES.
Yes I know this must be a bug. If you simply acknowlegde this as a bug and let me know of any workarounds and tell me you all are working on a solution and it will be out in some hotfix or release, you will make me happier.
I apologize for any inconvenience this problem may have caused you.
I modified the CustsViewModel ViewModel class by adding a property called DataTableWithData which is DataView type.
namespace BindAccess.ViewModels { public class CustsViewModel : ViewModelBase { private DataTable _dataTableWithData; public DataView DataTableWithData { get { if (_dataTableWithData == null) LoadData(); return _dataTableWithData.DefaultView; } } public IEnumerable ItemsSource { get { return new PagedCollectionView(DataTableWithData); } } private void LoadData() { _dataTableWithData = new DataTable(); _dataTableWithData.Columns.Add("ID"); _dataTableWithData.Columns.Add("Name"); _dataTableWithData.Columns.Add("Age"); for (int i = 0; i < 10; i++) { _dataTableWithData.Rows.Add(i.ToString(), "Name" + i.ToString(), i); } } } }
Exception happen when I tried to bind the ItemsSource property from CustsViewModel to ItemsSource property of UXGridView. I was able to bind the DataView to other controls such as UXListBox; UXComboBox; or UXPageableComboBox.
Currently, our team is investigating this issue. Should I heard any news regarding this, I will let you know.
Thank you so much Hans for looking into this!!! Yes, I was going to UXGridView with no success. Good to know that other controls are working! I will try this out. Let me know of a solution to UXGridView if you find one. Again, many thanks!
I found that when AutoGenerateColumns is disabled (AutoGenerateColumns=”False”) and UXGridView columns are defined, I can successfully display the items. I will keep you updated with anything I found.
Edited on: January 2, 2012 03:03 AMReason: Update information
You need to specify each column of UXGridView if bind the ItemsSource property to DataView object. For example:
ViewModel
using System.Collections; using System.Data; using Intersoft.Client.Data.ComponentModel; namespace BindAccess.ViewModels { public class CustsViewModel : ViewModelBase { private DataTable _dataTableWithData; public DataView DataTableWithData { get { if (_dataTableWithData == null) LoadData(); return _dataTableWithData.DefaultView; } } public IEnumerable ItemsSource { get { return new PagedCollectionView(DataTableWithData); } } private void LoadData() { _dataTableWithData = new DataTable(); _dataTableWithData.Columns.Add("ID"); _dataTableWithData.Columns.Add("Name"); _dataTableWithData.Columns.Add("Age"); for (int i = 0; i < 10; i++) { _dataTableWithData.Rows.Add(i.ToString(), "Name" + i.ToString(), i); } } } }
View
<Intersoft:UXPage.DataContext> <ViewModels:CustsViewModel /> </Intersoft:UXPage.DataContext> <Grid x:Name="LayoutRoot"> <Intersoft:UXGridView ItemsSource="{Binding ItemsSource}" AutoGenerateColumns="False"> <Intersoft:UXGridView.Columns> <Intersoft:UXGridViewTextColumn Header="ID" Binding="{Binding ID}"/> <Intersoft:UXGridViewTextColumn Header="Name" Binding="{Binding Name}"/> <Intersoft:UXGridViewTextColumn Header="Age" Binding="{Binding Age}"/> </Intersoft:UXGridView.Columns> </Intersoft:UXGridView> </Grid>
If you need UXGridView to automatically generate its columns (by enabling the AutoGenerateColumns property), it is suggested to use the WCF RIA service or DevForce.
Hope this helps.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname