Click here to Skip to main content
16,018,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am having a trouble with a pop up in silverlight. When i click on a button to open it throws the that error. Here i am pasting code .

<popup x:name="PopupNotification" verticaloffset="-400" horizontaloffset="200" xmlns:x="#unknown">
            <border removed="{StaticResource PanelBrush}" cornerradius="5" borderbrush="Black" margin="2,2,2,1">
                <!--<stackpanel orientation="Vertical">-->
                <usercontrols:notification x:name="UserControlNotification" xmlns:usercontrols="#unknown"></usercontrols:notification>
                <!--<stackpanel orientation="Horizontal" horizontalalignment="Center">
                        <Button Content="Ok"  Width="50" HorizontalAlignment="Right" Margin="0,4,4,4" Click="btnNotificationOK_Click"  x:Name="btnNotificationOK"/>
                        <Button Content="Cancel" Width="50" HorizontalAlignment="Right" Margin="10,4,4,4" Click="btnNotificationCancel_Click"  x:Name="btnNotificationCancel"/>
                    </stackpanel>-->
                <!--</stackpanel>-->
            </border>
        </popup>


and when on button click in code behind it throws error here.

PopupNotification.IsOpen = true;
Posted

1 solution

I notice that your popup contains a reference to a user control. In my experience, when this error occurs it is a problem in a child control and not at the level where the error is actually generated. The popup is likely being created correctly but when the runtime tries to create the usercontrol, it is failing. The usercontrol is likely generating a runtime exception that the popup is trapping, but is simply bubbling up as a COM error. I imagine if you look at the stack trace, you'll see the exception is on the constructor of the user control.

Try dropping the usercontrol on the main app page and instantiating it. I bet it throws an error there as well. If it is in the same project, you'll be able to debug it (provided SL debugging it setup) and find the error. If it is in another project, you'll have to setup a test page and debug it there.

Remember, with user controls it can be a problem in the XAML as well. Something as simple as referencing a static resource in the control template that isn't available at runtime can cause an exception in the user control. Isolation and testing is the key to tracking these bugs down.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900