Hi,
When a context menu is placed in the resources part as follows:And referred to like this:
Every time the contextmenu is invoked, an exception will occur that will crash the app with the following details:
An unhandled exception ('Unhandled error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.ArgumentException: Value does not fall within the expected range.
If the contextmenu is placed directly within the control (thus not using a static resource) it works as expected. However, I'm using the context menu in a DataTemplate for a listbox that can contain many items and I don't want the contextmenu to be created for each item, thats why I'm using a static resource.
Regards,
Robert Croshere
When a context menu is placed in the resources part as follows:
<UserControl.Resources>
<shared:ContextMenu
x:Key="menu">
<shared:MenuItem
Header="contexttest" />
</shared:ContextMenu>
</UserControl.Resources>
shared:ContextMenuService.ContextMenu="{StaticResource menu}"
An unhandled exception ('Unhandled error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.ArgumentException: Value does not fall within the expected range.
If the contextmenu is placed directly within the control (thus not using a static resource) it works as expected. However, I'm using the context menu in a DataTemplate for a listbox that can contain many items and I don't want the contextmenu to be created for each item, thats why I'm using a static resource.
Regards,
Robert Croshere