How to Cancel Datagrid selection changed event in WPF? -


I know that before this question has been asked, but I can not find what I'm looking for.

  Private Zero DataGrid 1_SelectionChanged (Object Sender, SelectionChangedEventArgs e) {if (oOrdItem.ItemNo == 0) {e.Handled = true; MessageBox.Show ("Please save items", "save"); Return; }}   

Even if I call e.handed = true; This will select the DataGrade line I dataGrid1.SelectedIndex = 1; Do not want to call because it will trigger the re-selection event. I also have dataGrid1.UnSelectAll (); Have tried any other way to cancel selections?

Do you think of an alternative implementation? I am thinking of a check method before changing binding and SelectedItem . One illustration:

  & lt; DataGrade ItemSource = "..." selectedEystem = "{Binding Selected Entry}" />   

and the underlying VM may look like this:

  public class sampleVM: seeModelBase // assuming that you use this kind of base class Are {Private Objects} Selected Entry; Public Entry Selected Entry {Get {return_selectedEntry; } Set {ifPHP (SavePrevItem ()) returns; _selectedEntry = value; RaisePropertyChanged ("SelectedItem"); // or something similar}} Private Butt Save Pravity () {// Your logic here}}    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -