My main UserControl is themed, so that the theme applies to all controls.
Now I want to open a ChildWindow:
ChildWindow w = new ChildWindow();
w.Show();
I get following exception:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.dll
[Main Thread] FATAL Unhandled exception Exception=Cannot resolve TargetName DisabledVisualElement. StackTrace= at MS.Internal.XcpImports.VisualStateManager_GoToState(Control reference, String StateName, Boolean useTransitions)
at System.Windows.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)
at System.Windows.Controls.Control.GoToState(Boolean useTransitions, String stateName)
at System.Windows.Controls.Primitives.ToggleButton.ChangeVisualState(Boolean useTransitions)
at System.Windows.Controls.Primitives.ButtonBase.UpdateVisualState(Boolean useTransitions)
at System.Windows.Controls.Primitives.ButtonBase.UpdateVisualState()
at System.Windows.Controls.Primitives.ButtonBase.OnIsEnabledChanged(IsEnabledChangedEventArgs e)
at System.Windows.Controls.Control.OnIsEnabledChanged(Control control, EventArgs args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Note that I don't set IsEnabled to false.
Comments: ** Comment from web user: devi_ous **
Now I want to open a ChildWindow:
ChildWindow w = new ChildWindow();
w.Show();
I get following exception:
A first chance exception of type 'System.InvalidOperationException' occurred in System.Windows.dll
[Main Thread] FATAL Unhandled exception Exception=Cannot resolve TargetName DisabledVisualElement. StackTrace= at MS.Internal.XcpImports.VisualStateManager_GoToState(Control reference, String StateName, Boolean useTransitions)
at System.Windows.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)
at System.Windows.Controls.Control.GoToState(Boolean useTransitions, String stateName)
at System.Windows.Controls.Primitives.ToggleButton.ChangeVisualState(Boolean useTransitions)
at System.Windows.Controls.Primitives.ButtonBase.UpdateVisualState(Boolean useTransitions)
at System.Windows.Controls.Primitives.ButtonBase.UpdateVisualState()
at System.Windows.Controls.Primitives.ButtonBase.OnIsEnabledChanged(IsEnabledChangedEventArgs e)
at System.Windows.Controls.Control.OnIsEnabledChanged(Control control, EventArgs args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Note that I don't set IsEnabled to false.
Comments: ** Comment from web user: devi_ous **
while it not fixed, you can mute exception in Application_UnhandledException handler(App.xaml.cs):
if (e.ExceptionObject.Message.Equals("Cannot resolve TargetName Root."))
{
e.Handled = true;
return;
}