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
Can you clarify what is Users in your DataContext? Is it ICollectionView similar to our demo?
Kind regards,Vlad
the Telerik team

That's it then, it's an ObjectContext (Entity Framework Model Instance). I assumed it implemented ICollectionView.
Thanks,
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.
Vlad
the Telerik team

Many thanks for the demo!
Regards,
Daryl

Right now my GridView is Binding to an ObservableCollection and I'm in doubt how to refactor this to ICollectionView.
Regards
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

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.
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

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
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