I want to have a remove treeviewlist item function, I use the latest telerik Silverlight control (April, 2010), VS 2010, entity framework, Ria service. I tried to remove the selected entity from entity collection directly, but the item still show on the treeviewlist even I set two way data binding mode for itemsource. Can you send me an example project that I can follow? Thank you very much!
4 Answers, 1 is accepted
If the ItemsSource of the TreeListView is observable it should update when an item is removed from its source.
I am attaching a project where this happens, using dummy data and an ObservableCollection<T>.
Is it possible that you are not assigning an observable source to the TreeListView?
Calling .ToList() for example will produce a non-observable collection.
Best wishes,
Miroslav
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.
Thank you for your response.
I load my treeviewlist like this.
Ria service
public IQueryable<Group> GetGroups ()
on the Page code behind
var query = this.nbt.GetGroupsQuery();
var loadOperation = this.nbt.Load(query, LoadBehavior.RefreshCurrent, false);
this.groupTreeListView.ItemsSource = loadOperation.Entities.Where(t => t.ParentGroup == null);
on Xaml
<telerikNavigation:RadTreeListView telerik:StyleManager.Theme="Windows7" x:Name="groupTreeListView">
I can remove the group from entity collection and database but the treelistview doesn't get refreshed.
How can I define databinding mode = "TwoWay" for itemsource in code behind?
Calling Where() on an observable collection returns a WhereEnumerator which is a non-observable enumerator that just walks the given collection. It will not notify its destination if the source changes.
this.groupTreeListView.ItemsSource = loadOperation.Entities.Where(t => t.ParentGroup == null);
There is a way to achieve this using a CollctionView:
var collectionView =
new
CollectionViewSource();
collectionView.Source = loadOperation.Entities;
collectionView.Filter += (s, e) => (e.Item
as
MyDataItem).ParentGroup ==
null
;
this
.groupTreeListView.ItemsSource = collectionView;
Hopefully this will help you,
Regards,
Miroslav
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.