Hi there.
So if you reference this post, http://www.telerik.com/community/forums/wpf/gridview/add-to-selecteditems-via-behavior.aspx you will see that Maya gave us some sample code with the custom behavior that lets us manipulate the selected items of a gridview from the code behind, i.e. changing the selected items list shows up on the grid as selected. the only problem is that we are changing the list of items that the SelectedItems property is bound to inside of the view model and not on the code behind for the page so we can't say something like
Any ideas on how we can make this work? I tried something like this in the view model
but that doesn't work. There is something I am missing here, some sort of notification is taking place when you say - MyRadGridView.SelecedItems.Add() that doesn't take place from the view model even thought they are the same collection of objects. If I could figure out what that is maybe I could figure out how to make this thing work.
Thanks for any help or suggestions...
So if you reference this post, http://www.telerik.com/community/forums/wpf/gridview/add-to-selecteditems-via-behavior.aspx you will see that Maya gave us some sample code with the custom behavior that lets us manipulate the selected items of a gridview from the code behind, i.e. changing the selected items list shows up on the grid as selected. the only problem is that we are changing the list of items that the SelectedItems property is bound to inside of the view model and not on the code behind for the page so we can't say something like
//This is from the window.xaml.cs file
((MyDataContext)
this
.LayoutRoot.DataContext).SelectedItems.Add(((MyDataContext)
this
.LayoutRoot.DataContext).Data.Where(x => x.ID == 4).First());
//This is from the view model
public
LineItem SelectedItem
{
get
{
return
selectedItem;
}
set
{
selectedItem = value;
selectedItems.Clear();
var list = Data.Where(x => x.OrderId == value.OrderId);
foreach
(var lineItem
in
list)
{
SelecedItems.Add(lineItem);
}
OnPropertyChanged(
"SelectedItem"
);
}
}
Thanks for any help or suggestions...