Syncing RadGridView and RadDataform with QueryableCollectionView

6 posts, 1 answers
  1. Johannes
    Johannes avatar
    66 posts
    Member since:
    Dec 2012

    Posted 22 Jan 2015 Link to this post

    I want to syncronize my RadGridView with my RadDataForm. Defining a CollectionViewSource in the XAML of the view bound to an ObservableCollection in the ViewModel does not work 100% because this will fail when we set a filter on the RadGridView. So after taking a look at your demos and manuals it seems that I have to use your QueryableCollectionView class to achieve correct syncronization.

    In your demo you use QueryableCollectionView inside your ViewModel but the class needs Telerik.Windows.Data and WindowsBase.dll. Both of this DLLs are imho attached to "view stuff" and should not be in the ViewModel. In my case my ViewModel project is a portable class library which makes it impossible to import any of those view related libraries.

    So here's the question? Can I use QueryableCollectionView in XAML like CollectionViewSource? If not how else can I get 100% working syncronization?
  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Jan 2015 Link to this post

    Hello,

    You can try a slightly different approach and achieve similar results. Basically, RadGridView uses DataitemCollection, which is Telerik's alternative to the .net itemsCollection, which uses a QueryableCollectionView to add IQueryableSupport. So that, if you bind RadDataForm's ItemsSource directly to RadGridVIew's Items property, RadDataForm will use RadGridView's QCV internally, instead of creating a new one and you will have synchronization. I am attaching a simple demo project.

    Regards,
    Ivan Ivanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Johannes
    Johannes avatar
    66 posts
    Member since:
    Dec 2012

    Posted 29 Jan 2015 Link to this post

    Thank you for your hint. It works. However this is getting difficult if RadGridView and RadDataForm are not directly in the same UserControl/XAML. If both controls are located in different child UserControls I can not use DataBinding with ElementName because RadDataForm does not know/find RadGridView.

    So for the moment I'm using a wrapper class containing the ViewModel class and the IQueryableCollectionView and this class is located in the View project. There I can add "view related stuff" to it.
  5. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 29 Jan 2015 Link to this post

    Hello,

    Well, these controls being in different views complicates the things. Does the solution with the wrapper class is appropriate for? if not, we can think of some attached behavior that propagates one and the same QCV instance as an ItemsSource for both of them?

    Regards,
    Ivan Ivanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Johannes
    Johannes avatar
    66 posts
    Member since:
    Dec 2012

    Posted 02 Feb 2015 in reply to Ivan Ivanov Link to this post

    In my opinion it's absolutely okay to have another small layer between View and ViewModel where I put things in that can not reside in the (portable class library) ViewModel project like IQueryableCollectionView. So yes, I'm fine with this solution.

    Thanks again for support.
  7. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 02 Feb 2015 Link to this post

    Hi,

    I am glad to hear that the issue is solved and I am closing the ticket for now. Please, feel free to open it again if you need any additional assistance.

    Regards,
    Ivan Ivanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WPF is Visual Studio 2017 Ready