ICollectionView Synchronization

11 posts, 1 answers
  1. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 17 Mar 2011 Link to this post

    Hi

    Forgive me if I'm asking something stupid. I'm fairly new to WPF.

    I'm trying to implement the demo inside an application I'm creating, but it's not synchronizing.

    Here's more or less what I have (because I tried isolating the code).

    <Window x:Class="AluminiumSystem.Dialogs.TestWindow"
            Title="TestWindow" Height="500" Width="500" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <telerik:RadDataForm Name="radColourForm" Grid.Row="0"  ItemsSource="{Binding Users}"/>
            <telerik:RadGridView Name="radColourGrid" Grid.Row="1" ItemsSource="{Binding Users}"  CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" />
        </Grid>
    </Window>
    public partial class TestWindow : Window
    {
        public TestWindow()
        {
            InitializeComponent();
     
            DataContext = new Entities();
        }
    }


    Edit: Content is synced (if I edit in form, it's immediately shown in grid) but selection isn't. 
    Edit2: Also, add & delete are disabled.

    Thanks in advance,
    Daryl
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 18 Mar 2011 Link to this post

    Hi,

     Can you clarify what is Users in your DataContext? Is it ICollectionView similar to our demo

    Kind regards,
    Vlad
    the Telerik team
  3. UI for WPF is Visual Studio 2017 Ready
  4. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 18 Mar 2011 Link to this post

    Hi Vlad,

    That's it then, it's an ObjectContext (Entity Framework Model Instance). I assumed it implemented ICollectionView.

    Thanks,
    Daryl
  5. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 18 Mar 2011 Link to this post

    Hello Daryl,

     Unfortunately none of these implements ICollectionView. You will need to wrap your original data in some ICollectionView in order to achieve your goal. 

    I've attached an example project to illustrate you this. 

    Kind regards,
    Vlad
    the Telerik team
  6. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 18 Mar 2011 Link to this post

    Hi Vlad,

    Many thanks for the demo!

    Regards,
    Daryl
  7. fbc
    fbc avatar
    11 posts
    Member since:
    Oct 2009

    Posted 25 Mar 2011 Link to this post

    Do you have any examples where this is done using MVVM pattern.
    Right now my GridView is Binding to an ObservableCollection and I'm in doubt how to refactor this to ICollectionView.

    Regards
    Flemming
  8. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 25 Mar 2011 Link to this post

    Hi Flemming,

    Not sure if this'll help (as I said I'm very new to WPF).

    Instead of wrapping the whole EF model, I'm converting the list before binding it. I have no idea how MVVM works (yet ;)) but maybe this'll help you achieve whatever you want to achieve.

    QueryableCollectionView collection = new QueryableCollectionView(UserManagementProcess.GetUserList());
                this.usersGrid.ItemsSource = collection;
                this.radUsersForm.ItemsSource = collection;

    UserManagementProcess.GetUserList returns a List of type User.

    Thanks,
    Daryl
  9. fbc
    fbc avatar
    11 posts
    Member since:
    Oct 2009

    Posted 25 Mar 2011 Link to this post

    Hi Daryl,

    Thanks for your reply; it made me think a second time, and, indeed, a CollectionView can easily replace an observableCollection; but one has to type the code in the right place :-)
    Now for the next problem (maybe Telerik Support has an answer):
    In addition to RadGridView and my new DataForm, I also have a RadTreeView; if I bind the same collectionView to all three, Grid and Form keep currentItem in sync; but TreeView does not follow. (Data look fine in the treeview, so the binding seems ok)

    Regards
    Flemming

    Edit: Looks like TreeView does not like CollectionView at all.
    If I apply a filter (in the GridView) TreeView is 'one behind' i.e. check 5 items in the filterbox, only 4 shown in treeview.
    If I then clear the filter, GridView shows all records; but treeview will show the first 5 !! in the collection.
  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 30 Mar 2011 Link to this post

    Hello Flemming Clausen,

    Could you please elaborate more on the steps you perform in reproducing this issue? It would be great if you can send us an isolated sample showing it so that we can investigate it in depth. It is possible that a part of the synchornization must be achieved in code behind using events of the CollectionView since the GridView has some synchronization properties that the treeview hasn't.

    Kind regards,
    Petar Mladenov
    the Telerik team
  11. AndyL
    AndyL avatar
    9 posts
    Member since:
    Mar 2011

    Posted 05 Jun 2011 Link to this post

    Hi Vlad,

    Thanks for the sample, very useful, however when I implemented it I was able to synchronize my grid with DataForm  by new ICollectionView object but I lost the possibilities to implement DataPager for this grid. DataPager as far as I understand expects sorted data source. ICollectionView in your example seems to be missing orderby method. Is there any way to satisfy both of them DataForm and DataPager at the same time?

    Thanks,

    Andy

  12. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 08 Jun 2011 Link to this post

    Hello Andy,

     Generally if you want to page an Entity Framework LINQ context you need to sort first - this is not related to the pager but to Entity Framework in general. 

    Regards,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready