When the user clicks on the run button on my app, I disable the editor by setting the SyntaxEditor's IsEnabed property to false.
I also want the user to be able to run a program via the F5 key, however when I disable the editor from this event I get an unhandled exception:
- Exception {"No installed components were detected. Cannot resolve TargetProperty Foreground on specified object."} System.Exception
at Windows.UI.Xaml.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)
at ActiproSoftware.UI.Xaml.Controls.SyntaxEditor.SyntaxEditor.UpdateVisualState()
at ActiproSoftware.UI.Xaml.Controls.SyntaxEditor.Primitives.EditorView.RaiseHasFocusChangedEvent()
at ActiproSoftware.UI.Xaml.Controls.SyntaxEditor.Primitives.EditorView.ProcessLostFocusWithin()
at ActiproSoftware.UI.Xaml.Controls.SyntaxEditor.Primitives.EditorView.OnLostFocus(RoutedEventArgs e)
It appears that the SyntaxEditor control crashes if IsEnabled is set to true when the control has focus.
Does anyone know of a workaround for this? Or another way of achieving the same thing?
I've tried setting the focus to another control before I set the IsEnabled property, but this doesn't seem to work.
If I don't set IsEnabled to false via the keyboard control it works. If I set IsEnabled to false via a click event there's no exception.
Cheers,
Phil