This is a migrated thread and some comments may be shown as answers.

GridView in UserControl

22 Answers 290 Views
GridView
This is a migrated thread and some comments may be shown as answers.
nbahl
Top achievements
Rank 1
nbahl asked on 22 Dec 2008, 04:26 PM
I have a WPF UserControl that has a GridView on it, when I place that UserControl in a WinForm application and try grouping by dragging the column header into the Grouping area it errors out.  The error I get is:

System.ArgumentNullException was unhandled
  Message="Value cannot be null.\r\nParameter name: otherVisual"
  Source="PresentationCore"
  ParamName="otherVisual"
  StackTrace:
       at System.Windows.Media.Visual.FindCommonVisualAncestor(DependencyObject otherVisual)
       at System.Windows.Media.Visual.TransformToVisual(Visual visual)
       at Telerik.Windows.Controls.DragDropManager.GetPopupPosition()
       at Telerik.Windows.Controls.DragDropManager.CreateDragAdorner()
       at Telerik.Windows.Controls.DragDropManager.PrepareElementToDrag(UIElement elementToDrag)
       at Telerik.Windows.Controls.DragDropManager.UIElement_MouseMove(Object sender, MouseEventArgs e)
       at System.Windows.Input.MouseEventArgs.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.RaiseEventImpl(DependencyObject sender, 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, Int32 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, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WinFormTestControl.Program.Main() in C:\rccdev\BankReconcilation\WinFormTestControl\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Any Ideas?

Thanks,
Nate

22 Answers, 1 is accepted

Sort by
0
Hristo Deshev
Telerik team
answered on 23 Dec 2008, 04:14 PM
Hello nbahl,

I have reproduced the bug, and it occurs only when hosting RadGridView in a WinForms application. I managed to fix it in our development version. If that is a blocking issue for you, please open a separate support ticket to request an unofficial build that contains the fix.

Thanks for the report! I have updated your Telerik points

Regards,
Hristo Deshev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
nbahl
Top achievements
Rank 1
answered on 29 Dec 2008, 10:45 PM
Thank you for fixing so quickly.  Do you have an estimate on how long it will be before the next release is available?  If its going to be a couple weeks I can wait but if longer I might need to request an unofficial build.

Thanks,
Nate
0
Milan
Telerik team
answered on 05 Jan 2009, 08:15 AM
Hi nbahl,

We have recently had our last release (December 17th) and the next one is a couple of months away. If that is inconvenient for you may open a support ticket and request an unofficial build.

Kind regards,
Milan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ben
Top achievements
Rank 1
answered on 15 Jan 2009, 07:08 PM
We have received the unofficial build of RadGridView that fixed the bug when grouping in a RadGridView hosted in a WinForms application.  Grouping now works as it should in most cases, however, when the RadGridView is put inside of a <Viewbox> in this situation, and I try grouping again, I am now receiving an error    "Unable to cast object of type 'System.Windows.Media.ContainerVisual' to type 'System.Windows.UIElement'."

Any ideas as to the cause of this error?

Thanks
Ben
0
Jordan
Telerik team
answered on 20 Jan 2009, 11:56 AM
Hi Ben,

This is another bug in our drag and drop. It is fixed and the new build is attached.

Kind regards,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 24 Apr 2013, 03:21 PM
We have been using RadGridView grouping fine in a WinForms project all the way up until updating to 4.0 and upgrading our Telerik assemblies to that of 2013.1.403.40. Could this be a regression?

System.ArgumentNullException occurred
  HResult=-2147467261
  Message=Value cannot be null.
Parameter name: otherVisual
  Source=PresentationCore
  ParamName=otherVisual
  StackTrace:
       at System.Windows.Media.Visual.FindCommonVisualAncestor(DependencyObject otherVisual)
       at System.Windows.Media.Visual.TransformToVisual(Visual visual)
       at Telerik.Windows.Controls.UIElementExtensions.TransformToVisualSafe(UIElement target, UIElement element) in c:\TB\221\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Common\UIElementExtensions.cs:line 17
  InnerException:

0
Yordanka
Telerik team
answered on 25 Apr 2013, 08:55 AM
Hi Jeff,

Thank you for the feedback.

We were not able to reproduce the reported exception. Could you send us more details about your implementation or a sample project which shows the problem?
 
Kind regards,
Yordanka
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Lenka
Top achievements
Rank 1
answered on 24 Jun 2013, 09:56 PM
Hi,
I've got the same error today when im trying to sort a grid. My application is "hosting RadGridView in a WinForms application"

Any idea how to fix it?
0
Yordanka
Telerik team
answered on 25 Jun 2013, 07:39 AM
Hi Lenka,

Could you test your solution with the latest official version Q2 2013? Please let me know if the problem still persists.
 
Regards,
Yordanka
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Lenka
Top achievements
Rank 1
answered on 25 Jun 2013, 02:21 PM
We are using the 2013.1.220.40 version

0
Yordanka
Telerik team
answered on 26 Jun 2013, 11:58 AM
Hello Lenka,

The problem has been fixed with Q2 2013 official version.  Please give it a try and let us know if you find any problems.
 
Regards,
Yordanka
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lenka
Top achievements
Rank 1
answered on 26 Jun 2013, 09:24 PM
Thank you.
It works well with new version of dll's
0
Lenka
Top achievements
Rank 1
answered on 22 Aug 2013, 11:08 PM
Now i found new bug. When i added  CanUserReorderColumns="True" to GridView, i've got problems with styles.
Before column reordering i have a perfect grid with standart style (Windows8). But after the 2nd reorder the style changed to OfficeBlack.




<telerik:RadGridView Grid.Row="1" 
Margin="0"                            
ItemsSource="{Binding LIST}"
 IsFilteringAllowed="True"
SelectionMode="Extended" 
 CanUserResizeColumns="True"
CanUserReorderColumns="True"
AutoGenerateColumns="False"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
 FilteringMode="Popup"
DataLoaded="List_DataLoaded" 
 DistinctValuesLoading="OnDistinctValuesLoading"
 >
 <telerik:RadGridView.Columns>...

0
Lenka
Top achievements
Rank 1
answered on 22 Aug 2013, 11:14 PM
I already tried add  telerik:StyleManager.Theme="Windows8Theme" or changed standard style, but it didnt fixed issue

Could you tell me how can i rewrite Column Drag and Drop template for grid view?
0
Nick
Telerik team
answered on 26 Aug 2013, 09:32 AM
Hello Elena,

Unfortunately this is an issue we have never encountered before. May I ask you to share a bit more info about the scenario? Do you have any custom styles? A sample project that isolates the problem would be very helpful! 

Thank you in advance! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lenka
Top achievements
Rank 1
answered on 27 Aug 2013, 02:38 AM
sorry, i couldn't create a small project because for windows forms we used Infrajistic (maybe that the problem). 
I almost fixed issue with reordering, but i still need help to rewrite standard DragAndDrop Column style. Could you tell me what template i should change?
0
Nick
Telerik team
answered on 28 Aug 2013, 02:39 PM
Hi Elena,

Can you clarify what exactly do you mean by DragAndDrop Column style?

Thank you in advance! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lenka
Top achievements
Rank 1
answered on 28 Aug 2013, 05:15 PM
I'm sorry. Template for Drag preview?

like on the picture (for treeView) http://www.telerik.com/help/silverlight/media/RadTreeView-DragDrop-VisualElements.png

Unfortunately we  could see DragPreview and DropPreview Line 




0
Nick
Telerik team
answered on 02 Sep 2013, 10:52 AM
Hi Elena,

Unfortunately there is no way to do this out of the box. 

The GrdView and TreeView are quite different and provide different level of User experience.

Nevertheless there is a way to achieve what you want. 
To change the DragVisual, you need to handle the DragInitialize event with HandledEventsToo set to true, where you can set the DragVisual to whatever you need it to be. 

As to the PreviewDropLine, you can see how this can be done here.

Hope this helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lenka
Top achievements
Rank 1
answered on 16 Sep 2013, 02:44 AM
I have a simple example with discussed problem. When i reorder column (the second time) I couldn't see DragPreview template.
I can see its only for first time reordering.



PS I disabled all my styles and used everything by default.

PS I dont know how to attach zip file, so this is the link to http://www13.zippyshare.com/v/5204300/file.html
0
Nick
Telerik team
answered on 18 Sep 2013, 02:04 PM
Hi Elena,

I took a look at your project, and after some debugging found out what goes wrong. 

The DragVisual in WPF is contained in a WPF window, which is a new instance for every drag operation. 
The thing is, that for some reason, once a WPF window has been opened in your application, you can never open another one. I trust this is an issue connected with the WinForms host application, that goes beyond our scope. 

I am attaching a modified version of your project where you can see the problem I am referring to clearly. 

Hope it helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Lenka
Top achievements
Rank 1
answered on 19 Sep 2013, 05:09 PM
Hi, Nik
Thanks for the clarification and  good example. It looks weird and I guess we will spend lot of time to fixed it :(
And thank you so much for all your help I really appreciate it.
Tags
GridView
Asked by
nbahl
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
nbahl
Top achievements
Rank 1
Milan
Telerik team
Ben
Top achievements
Rank 1
Jordan
Telerik team
Jeff
Top achievements
Rank 1
Yordanka
Telerik team
Lenka
Top achievements
Rank 1
Nick
Telerik team
Share this question
or