i have code like
e.CanExecute = tabEditor.IsFocused;
but at runtime, i get a null reference exception error. but in the docs, IsFocused
returns only true or false, why is this happening? btw, tabEditor
is a <TabItem>
i have code like
e.CanExecute = tabEditor.IsFocused;
but at runtime, i get a null reference exception error. but in the docs, IsFocused
returns only true or false, why is this happening? btw, tabEditor
is a <TabItem>
Most likely, this is happening because at some point tabEditor is being set to null.
Chances are that either e
or tabEditor
is null, i.e., they weren't assigned to an object anywhere (or otherwise explicitly assigned to null
). If the code is in an event handler, it's possible that the framework hasn't initialized all the variables by the time the event handler is called, in which case you might want to check for null.