Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was surprised to find the Silverlight is severly lacking in this functionality, considering all the business oriented RIA functionality. AutoCommit is not acceptable to me because I want the user to explicitly acknowledge pending changes, rather than just commit something to the database that they may not want.</p> <p>You can reliably track the edit mode of the DataForm using a private member variable and trapping the BeginningEdit and EditEnded events of the DataForm (naming inconsistency! Why one is called xxxEdit and the others are Editxxx is beyond me. Should it not be <em>EditBeginning</em> and EditEnded??). Inside the event handler for BeginningEdit, set the flag to true and set it to false in EditEnded.</p> <p>In your SelectionChanged event, you can then check the flag. If it is true, you can call the CancelEdit on the DataForm.</p> <pre><code>private bool _editing = false; public MainPage() { DataForm1.BeinningEdit += new EventHandler&lt;CancelEventArgs&gt;(DataForm1_BeginningEdit); DataForm1.EditEnded += new EventHandler&lt;DataFormEditEndedEventArgs&gt;(DataForm1_EditEnded); } protected void DataForm1_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e) { _editing = true; } protected void DataForm1_EditEnded(object sender, DataFormEditEndedEventArgs e) { _editing = false; } void TreeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs&lt;object&gt; e) { if (_editing) { object previous = DataForm1.SelectedItem; object current = TreeView1.SelectedItem; if (MessageBox.Show("Are you sure you want to cancel the changes?", "Confirm", MessageBoxbutton.OKCancel) == MessageBoxResult.OK) { DataForm1.CancelEdit(); } else { TreeView1.SelectedItem = previous; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload