Skip to main content

Microsoft Silverlight

Answered Question #4002 error when changing VisibiltyRSS Feed

(0)

boardz
boardz

Member

Member

15 points

12 Posts

#4002 error when changing Visibilty

Hello

Not sure if this has been reported, but when i change the Visibility of a Button control i get the following error:

ExceptionObject {System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.
   at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name, CValue[] cvData)
   at System.Windows.DependencyObject.MethodEx(String methodName, CValue[] cvData)
   at System.Windows.UIElement.ReleaseMouseCapture()
   at System.Windows.Controls.Primitives.ButtonBase.ReleaseMouseCaptureInternal()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object sender, MouseButtonEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)} System.Exception

 

Changing the Visibility of a TextBox and TextBlock are fine

Here the section of my code, it's pretty straight forward:

 

public static readonly DependencyProperty CurrentModeProperty = DependencyProperty.Register("CurrentMode", typeof(ControlMode), typeof(MyClass), new PropertyChangedCallback(CurrentModeChangedCallback));

private static void CurrentModeChangedCallback(DependencyObject obj, DependencyPropertyChangedEventArgs args)

{

MyClass ctrl = (MyClass)obj;

ctrl.butSettings.Visibility = Visibility.Collapsed;

ControlMode oldValue = (ControlMode)args.OldValue;ControlMode newValue = (ControlMode)args.NewValue;

 

ControlModeChangedEventArgs e = new ControlModeChangedEventArgs(newValue);

ctrl.OnControlModeChanged(e);

}

 

hope that helps

 boardz

Yi-Lun Luo - MSFT
Yi-Lun L...

All-Star

All-Star

25052 points

2,747 Posts

Answered Question

Re: #4002 error when changing Visibilty

Hello, from the stack trace, it looks like you're setting the Button's Visibility to Collapsed in its Click event handler. This is a known issue. But I just tried that on an internal Beta2 build, and it works fine. So hopefully this issue has already been fixed. Meanwhile you can set Opacity to 0 or set Both Width and Height to 0.

shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.

boardz
boardz

Member

Member

15 points

12 Posts

Re: #4002 error when changing Visibilty

Hi Yi-Lun thanks for the reply. Yes i have a work around at the moment, in fact the bug has led me to a better design.

 internal Beta2 hey! Do we proles get to have a squiz with Beta2 or do we have to wait for the Release.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities