Well, someone can tell me why this exception occurs in these conditions?
Test Window:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"><StackPanel><ComboBox
Name="cmbTest"
IsEditable="True"
SelectionChanged="ComboBox_SelectionChanged"></ComboBox></StackPanel></Window>Code behind:
Class MainWindow
Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim source As New ObservableCollection(Of String)()
source.Add("AAA")
source.Add("BBB")
source.Add("CCC")
cmbTest.ItemsSource = source
End Sub
Private Sub ComboBox_SelectionChanged(sender As System.Object, e As System.Windows.Controls.SelectionChangedEventArgs)
Keyboard.Focus(cmbTest)
End Sub
End ClassNow, if you type "AAA" and then "Ctrl+Z", combobox control raise this exception "Cannot Undo or Redo while undo unit is open."
Someone can explain why?!? ...how it would be possible to avoid it?