Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

#4002 error when changing Visibilty RSS

2 replies

Last post May 16, 2008 09:15 AM by boardz

(0)
  • boardz

    boardz

    Member

    15 Points

    12 Posts

    #4002 error when changing Visibilty

    May 14, 2008 08:09 PM | LINK

    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 Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: #4002 error when changing Visibilty

    May 16, 2008 07:58 AM | LINK

    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

    15 Points

    12 Posts

    Re: #4002 error when changing Visibilty

    May 16, 2008 09:15 AM | LINK

    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.