(New user of xamDataGrid 8.1)
My ultimate goal is to be able to perform my logic in my viewmodel class.
I am binding the grid to an XmlDataProvider, and currently I've got it to work sort of by hooking the SelectedItemsChanging event and adding a dummy xml attribute to the bound data indicating if it is selected or not. While seems to work it feels like a hack.
Would it possible to directly bind the IsSelected of a datarecord to an xml attribute?
Is there a better way to make the viewmodel aware of currently selected items/records without taking a reference to the grid?
Hello,
@ sdahlbac : Would it possible to directly bind the IsSelected of a datarecord to an xml attribute?
You can get the attribute of the xml node with XPath and then manipulate it and bind it to the IsSelected property. Here are examples of XPath syntax :
http://www.w3schools.com/XPath/xpath_syntax.asp
Hello RAlexander,
Sure, that would be good, just to make sure -- and I am starting from this MVVM article here:
http://msdn.microsoft.com/en-us/magazine/dd419663.aspx
and then trying to connect to what you post here, I guess you would like to sync the currently selected record to the collection, e.g. let's try this with CollectionView
customers = new ObservableCollection<DemoCustomer>(); cars.Add(new Cars("Car1", "Blue")); cars.Add(new Cars("Car2", "Black")); cars.Add(new Cars("Car3", "Green")); cars.Add(new Cars("Car4", "Red")); cars.Add(new Cars("Car5", "Orange")); customers.Add(new DemoCustomer("Alex", "2222222", cars)); customers.Add(new DemoCustomer("Peter", "2352222", cars)); customers.Add(new DemoCustomer("George", "22423222", cars)); customers.Add(new DemoCustomer("Dimitri", "228672222", cars)); customers.Add(new DemoCustomer("John", "222675622", cars)); cv = new CollectionView(customers); XamDataGrid1.DataSource = cv;
cv.MoveCurrentToNext();
...
then this would map the currently selected row in datasource to the currrently selected row in the grid? Unfortunately I was able to do that for ListControls only (as demonstrated in the article at the top) and for grid -- possible, but with a few lines of code. Hopefully someone else will correct me ere if I am wrong.
In any case, this is something which I believe is a good idea and can be suggested directly to our PMs via the following URL
Request a Feature or Component
Yes, that's what I'm trying to accomplish by the XamDataGrid supporting Currency. It's currently listed in the documentation that this is supposed to be rectified with a hot fix but its been a few releases since that was originally stated and still its not been added. Josh Smith has a workaround for this but it would be nice if the grid supported IsSyncedWithCurrentItem property out of the box.