This is a migrated thread and some comments may be shown as answers.

ICollectionView Synchronization

10 Answers 262 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 17 Mar 2011, 08:54 PM
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

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Mar 2011, 08:26 AM
Hi,

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

Kind regards,
Vlad
the Telerik team
0
Alan
Top achievements
Rank 1
answered on 18 Mar 2011, 08:41 AM
Hi Vlad,

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

Thanks,
Daryl
0
Accepted
Vlad
Telerik team
answered on 18 Mar 2011, 09:14 AM
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
0
Alan
Top achievements
Rank 1
answered on 18 Mar 2011, 09:21 AM
Hi Vlad,

Many thanks for the demo!

Regards,
Daryl
0
fbc
Top achievements
Rank 2
answered on 25 Mar 2011, 12:02 PM
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
0
Alan
Top achievements
Rank 1
answered on 25 Mar 2011, 12:19 PM
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
0
fbc
Top achievements
Rank 2
answered on 25 Mar 2011, 01:41 PM
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.
0
Petar Mladenov
Telerik team
answered on 30 Mar 2011, 05:07 PM
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
0
AndyL
Top achievements
Rank 1
answered on 05 Jun 2011, 09:54 PM

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

0
Vlad
Telerik team
answered on 08 Jun 2011, 09:03 AM
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
Tags
TreeView
Asked by
Alan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Alan
Top achievements
Rank 1
fbc
Top achievements
Rank 2
Petar Mladenov
Telerik team
AndyL
Top achievements
Rank 1
Share this question
or