Home Forums WPF controls Xceed DataGrid for WPF Datagrid and ORM tools

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24028 |

    Can anyone shed some insight on using the wpf data grid with ORM tools?
    I have had very bad luck so far. My commercial product did not support the needed interfaces (for xceed grid or WPF in general) so I switched to NHibernate. It seems to have good binding support for objects, but I am having difficulty understanding how to make collections work with the grid.
    When I bind a grid to a collection I am unable to add rows, and update to objects sometimes show in the grid, sometimes they do not.

    A simple NHibernate Xceed Grid sample with insert, update and deletes would be very helpful.

    M

    Imported from legacy forums. Posted by Mike (had 497 views)

    User (Old forums)
    Member
    Post count: 23064

    Checkout DevExpress eXpress Persistent Objects (XPO).

    I’m having good success with using this ORM with Xceed DataGrid.

    I use a DataGridCollectionView to wrap my XPO collection as shown below.

    The Xceed doc on the DataGridCollectionView may be found at
    http://doc.xceedsoft.com/products/XceedWpfDataGrid/DataGridCollectionView%20Class.html

    Also, check out the info on MSDN for WPF binding for more context.
    http://msdn2.microsoft.com/en-us/library/system.windows.data.collectionviewsource.aspx
    http://msdn2.microsoft.com/en-us/library/ms752347.aspx#binding_to_collections

    <code>
    // See the following post for an explanation of why the XpoCollection is cast to an IBindingList
    // ** http://forums.xceed.com/forums/ShowPost.aspx?PostID=7808
    // NOTE: If a collection implements INotifyCollectionChanged, the adding doesn’t work properly. That’s why
    // with XPO we have to extract the IBindingList from the BindingListCollectionView,
    // because BindingListCollectionView implments INotifyCollectionChanged.

    BindingListCollectionView bindingListView = CollectionViewSource.GetDefaultView(TheXpoCollection) as BindingListCollectionView;

    IBindingList ibl = (IBindingList)TheXpoCollection;

    DataGridCollectionView dgcv = null;
    if (ibl != null)
    {
    dgcv = new DataGridCollectionView(ibl);
    }
    else
    {
    dgcv = new DataGridCollectionView(bindingListView);
    }
    </code>

    Brian Noyes provides good insight on some of the interfaces involved in data binding as they relate to Windows Forms, but it’s doesn’t deal with WPF at all:

    Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET (Microsoft .NET Development Series) (Paperback)

    Imported from legacy forums. Posted by Richard (had 2772 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.