Welcome to the Xceed Community Sign in | Join | Help
Community Search  

DataGridControl, DataGridCollectionView, and Interface Inheritance

Sort Posts: Previous Next
  •  07-31-2008, 4:36 AM Post no. 13815

    DataGridControl, DataGridCollectionView, and Interface Inheritance

    Hi,

    I'd like to ask a couple of questions as follows:

    1. I've just been trying out DataGridControl and somehow I found that its collection data binding still fails miserably just like stuffs in System.Windows.*. Simply, it doesn't work the way I want when it comes to interface inheritance, especially when using Xceed.Wpf.DataGrid.DataGridCollectionView.
      Consider the following scenario: I have an IEntity interface, an IAccountEntity interface which implements IEntity (IAccountEntity : IEntity). Then I have a list of AccountEntity (a class which implements IAccountEntity) contained in List<IAccountEntity>. When I try to cast down the collection to IEnumerable<IEntity> (using System.Linq.Cast<T>), then suddenly DataGridCollectionView fails to indentify that its underlying type is still actually an AccountEntity. Further, if I set the DataGridControl.AutoCreateColumns to true then some properties from IAccountEntity isn't showed up at all.
      After digging deeper, I came up with a fact that the DataGridCollectionView is still using System.Windows.Forms.ListBindingHelper.GetListItemType() that caused the incorrect type inference. It also answers my other own question about why Xceed.Wpf.DataGrid.dll still references System.Windows.Forms.dll.
      So is this going to be fixed the next version?
    2. Why does DataGridControl have ReadOnly property instead of IsReadOnly one? Is this another mistake just like UIElement.Focusable that actually should be IsFocusable?

    Thanks!


    Regards,

    Maximilian Haru Raditya
  •  08-19-2008, 3:14 AM Post no. 14185 in reply to 13815

    Re: DataGridControl, DataGridCollectionView, and Interface Inheritance

    Just tried the new v3.0. But unfortunately, the bug is getting worse.

    As I want to re-explain my example above:

    - interface definition = IEntity

    - interface definition = IAccountEntity : IEntity

    - class definition = Entity : IEntity

    - class definition = AccountEntity : Entity, IAccountEntity, IEntity

    I have a data source in a form of collection of AccountEntity, but cast-down in the form ICollection<IEntity>.

    Now that using v3.0, there are two obvious results obtained

    1. The type of the collection (from the VS Visual Debugger) is IEntity, instead of AccountEntity.

    My poing is that although ICollection<AccountEntity> has been casted down to ICollection<IEntity>, the object in it is actually still an AccountEntity, not an IEntity.

    2. Using AutoCreateColumns set to true, it turns out that only properties from IEntity are shown. Other properties from AccountEntity, IAccountEntity, and Entity are completely missing.

    So, is there any good explanation for this? Am I missing something here?

    Thanks!

     

     

    P.S.:

    - one good thing I observed, the data grid assembly doesn't refer to System.Windows.Forms.dll assembly anymore. +1

    - still no further explanation about ReadOnly property name, which should be, IMO, IsReadOnly (BTW, I just notice that DepedencyProperty also use "ReadOnly" for one of its property name, hmm...)


    Regards,

    Maximilian Haru Raditya
  •  08-19-2008, 8:16 AM Post no. 14190 in reply to 14185

    Re: DataGridControl, DataGridCollectionView, and Interface Inheritance

    Hi Maximilian,

      The behavior you are experiencing is by design.

      Since you passed to the DataGridControl`s ItemSource ( or DataGridCollectionView`s Source ) a collection of IEntity, we respect the encapsulation brought forth by the list type and only detect the properties of IEntity.

     If you wish to see columns created for the properties the AccountEntity type, then I suggest NOT casting the collection to a list of IEntity OR I suggest creating the columns manually for the properties of AccountEntity.

    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  08-21-2008, 12:39 AM Post no. 14278 in reply to 14190

    Re: DataGridControl, DataGridCollectionView, and Interface Inheritance

    Hi,

    So, I see two options you proposed. I've tried #2 (creating column manually). Now, it's great that I can see whatever properties I expect to see. Unfortunately, the sorting just worked for the IEntity's properties, for other properties from other than IEntity, it simply just didn't work. So is this by design too?

    Thanks!


    Regards,

    Maximilian Haru Raditya
  •  08-21-2008, 1:10 PM Post no. 14327 in reply to 14278

    Re: DataGridControl, DataGridCollectionView, and Interface Inheritance

    In fact, to enable the Sorting, you would have to create DataGridItemProperties for the IEntity's property as well.

    <xcdg:DataGridCollectionViewSource x:Key="cvs" Source="{Binding myDataSource}" >
       <xcdg:DataGridCollectionViewSource.ItemProperties>
           <xcdg:DataGridItemProperty Name="PropName" DataType="{x:Type propType}" />
       </xcdg:DataGridCollectionViewSource.ItemProperties>
    </xcdg:DataGridCollectionViewSource>



    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
  •  08-25-2008, 12:39 AM Post no. 14429 in reply to 14327

    Re: DataGridControl, DataGridCollectionView, and Interface Inheritance

    Ah, IC...

    Thanks Marcus for all your help!


    Regards,

    Maximilian Haru Raditya
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.