I am having a problem with XamContextMenu. I've just started to look at it but at the moment I cannot get it to work at all.
I am using the most basic example straight from the documentation:
<TextBox Height="23" HorizontalAlignment="Left" Margin="68,30,0,0" Name="textBox1" VerticalAlignment="Top" Width="120">
<ig:ContextMenuService.Manager>
<!--If you use the Infragistics Commanding Framework, you should set the OpenMode property to None-->
<ig:ContextMenuManager ModifierKeys="Shift" OpenMode="RightClick">
<ig:ContextMenuManager.ContextMenu>
<ig:XamContextMenu Name="contextMenu2">
<ig:XamMenuItem Header="Font" />
<ig:XamMenuItem Header="Formatting" />
</ig:XamContextMenu>
</ig:ContextMenuManager.ContextMenu>
</ig:ContextMenuManager>
</ig:ContextMenuService.Manager>
</TextBox>
When I run this and try to invoke the context menu (Shift + Right mouse click), I get a run-time exception:
Unable to cast object of type 'Infragistics.Controls.Menus.XamContextMenu' to type 'Infragistics.Controls.Menus.XamMenu'.
I am using InfragisticsWPF4.v10.3 library. I have tried it for different controls - no luck, the same exception.
What is wrong here?
Hi,
I tried to reproduce your issue but without success. Could you please let me know the build number you are using - it can be seen as the 'Version' property of any of our assemblies, e.g. 10.3.20103.2065?
Could you provide any other additional information, maybe something about your page and other controls on it, etc. Ideally, you could send me a separate project sample where the issue is reproducible.
Thanks,
Thanks Stoimen. I am using 10.3.20103.1003.
Sorry, your other questions: it is a very simple app - I just created it from scratch to get the context menu working at all. Just one window and the text box I posted above. Nothing else there.
The answer georgi provided above should solve your issue - basically you just need to update to the latest Service Release to have that issue solved.
HTH,
Did you try applying any recent Service Release ?
As I stated above, this looks like an issue we had in 10.3 RTM build. Applying the latest Service Release should fix the problem.
Regards,
I am getting the same issue. I use 2010 v3.
{"Unable to cast object of type 'Infragistics.Controls.Menus.XamContextMenu' to type 'Infragistics.Controls.Menus.XamMenu'."}
System.InvalidCastException was unhandled
Message=Unable to cast object of type 'Infragistics.Controls.Menus.XamContextMenu' to type 'Infragistics.Controls.Menus.XamMenu'.
Source=InfragisticsWPF4.Controls.Menus.XamMenu.v10.3
StackTrace:
at Infragistics.AutomationPeers.XamContextMenuAutomationPeer.get_OwningContextMenu()
at Infragistics.AutomationPeers.XamContextMenuAutomationPeer.GetChildrenCore()
at System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
at System.Windows.Automation.Peers.AutomationPeer.GetChildren()
at System.Windows.Automation.Peers.AutomationPeer.isDescendantOf(AutomationPeer parent)
at System.Windows.Automation.Peers.AutomationPeer.ValidateConnected(AutomationPeer connectedPeer)
at System.Windows.Automation.Peers.AutomationPeer.AutomationPeerFromInputElement(IInputElement focusedElement)
at System.Windows.Automation.Peers.AutomationPeer.RaiseFocusChangedEventHelper(IInputElement newFocus)
at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.UIElement.Focus()
at Infragistics.Controls.Menus.XamContextMenu.Popup_Opened(Object sender, EventArgs e)
at System.Windows.FrameworkElement.RaiseClrEvent(EventPrivateKey key, EventArgs args)
at System.Windows.Controls.Primitives.Popup.OnOpened(EventArgs e)
at System.Windows.Controls.Primitives.Popup.CreateWindow(Boolean asyncCall)
at System.Windows.Controls.Primitives.Popup.OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Controls.Primitives.Popup.set_IsOpen(Boolean value)
at Infragistics.Controls.Menus.XamContextMenu.OnContextMenuOpened()
at Infragistics.Controls.Menus.XamContextMenu.OnIsOpenChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
at Infragistics.Controls.Menus.XamContextMenu.set_IsOpen(Boolean value)
at Infragistics.Controls.Menus.ContextMenuService.PositionContextMenu(XamContextMenu contextMenu, Point p, UIElement parentElement)
at Infragistics.Controls.Menus.ContextMenuManager.OpenContextMenu(Object sender, Point p)
at Infragistics.Controls.Menus.ContextMenuManager.Element_MouseRightButtonUp(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at XamPivotTest.App.Main() in C:\Users\schinnasamy\Documents\Visual Studio 2010\Projects\XamPivotTest - Sample\XamPivotTest\obj\x86\Debug\App.g.cs:line 0
InnerException:
Hello Igor,
I am just checking the progress of this issue and was wondering if you got this working, or if you need any further assistance on the matter.
If the above suggestion helped you solve your issue please verify the thread as answered so other users may take better advantage of it.
Sincerely,Petar MonovDeveloper Support EngineerInfragistics Bulgariawww.infragistics.com/support
Thanks Stoimen and Georgi. I will try that.