Exception when setting IsEnabled on control via keyboard event

SyntaxEditor for Universal Windows Forum

Posted 7 years ago by Phillip Trelford
Version: 14.2.0152
Avatar

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

Comments (2)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Philip,

Thanks for reporting this.  There is a bug in the default style for SyntaxEditor that is causing this that we have fixed for the next version.

As a workaround, instead of disabling the control, I would recommend that you set editor.Document.IsReadOnly = true.  That will still allow the user to move through the editor but they won't be able to alter it.  That's probably a better way to do this sort of thing anyhow.


Actipro Software Support

Posted 7 years ago by Phillip Trelford
Avatar

Thanks for the quick response, the suggested workaround worked for me, 

Cheers, Phil

The latest build of this product (v2020.1 build 0355) was released 18 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.