This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Have possibly got a project coming up to do some CRUD work on some DB tables – so am having a play-around with trial versions of Lightspeed and WPF Elements (downloaded 27/04/2015). Am also giving the MVVM pattern a go – trying to follow your excellent guide to MVVM and Caliburn. All going well – but have got an issue with the WPF DataGrid. Am trying to get the SELECTED ROW back from the datagrid so that I can put it into a pop-up windows so the user can update or delete. Code is in the BlackView.xaml and BlackViewModel.cs files In the datagrid, I have attached the SelectionChanged event with the following XAML cal:Message.Attach="[Event SelectionChanged] = [Action SelectedIndex($dataContext)]"> and then try and pick this up in the Model public void SelectedIndex(object cfrr) {
} But the object cfrr is of type GCH_CentralPrcing.BlackViewModel rather than CATEGORYNAME type (which is the data in the data grid) So How do I get the selected row to be passed back from the DataGrid ? (Code in attached ZIP file) |
|
|
Hi Mark, Thanks for trying out LightSpeed and WPF Elements. In Caliburn, $dataContext will return the DataContext of the UI Element that sent the event. The SelectionChanged event is on the DataGrid, and so you get back the DataContext of the DataGrid which is the BlackViewModel. I recommend changing this to $eventArgs which will give you a SelectionChangedEventArgs object. the row model object that you want (CATEGORYNAME) will be in e.NewItems[0] (Make sure to do a count check first so you don't get index-out-of-bounds). Please let me know if you have further questions about WPF Elements -Jason Fauchelle |
|