Hi,
I am working with XamGrid (I know it is recommended to move to XamDataGrid, but that's problematic for this specific grid).
The grid behaves weird when the data in the columns needs scrolling for some of the columns.
Once I select a line (using mouse) with a long text within one of the columns, the H-scroll jumps to the end of the grid.
When I scroll to the start and click on another line, which is shorter, the scroll sometimes jumps to the end and sometimes does not.
I've attached a sample class that shows this beahvior.
also I've added images:
1 - showing the state after selection of line X
2- showing the scroll I've manually changed, before selection of line Y (highlighted)
3 - showing the state after I've clicked on that line.
please advise how can I turn-off the scroll sauto-jump' behavior or any other workaround to solve this
Thanks
Hello Eli,
Thank you for your post.
I have been investigating into this behavior you are seeing with the XamGrid control, and I have reproduced it. As you have mentioned in your original description, I would recommend moving the XamDataGrid control if at all possible, as the XamGrid is essentially a retired control at this point.
You mentioned that this migration is problematic for that specific grid. I am curious as to why? From your screenshots, it does not appear that you are implementing any sort of feature that the XamDataGrid does not have that the XamGrid does. That list at this point is essentially limited to numbered paging, as the XamDataGrid can do everything else that the XamGrid does, and it generally does it better and in a more performant way.
I have been investigating into a potential workaround for this issue, but unfortunately, I do not believe there is going to be a simple one, as the “scroll into view” behavior is handled entirely internal to the grid when a cell is activated, and there does not exist a way to shut that off without shutting cell activation off entirely. I believe what is happening is that there is likely code in place that is scrolling the horizontal scrollbar to its maximum value if the last column is activated, leaving this case where if the column is larger than the width of the grid, you will see the behavior you are seeing. I am unsure why it works normally only sometimes.
This behavior is unexpected, and as such I have asked our engineering staff to examine it further. I have logged this behavior in our internal tracking systems with a development ID of 273165. I have also created you a private support case that I will be linking this issue to. It has an ID of CAS-213478-J4P5V4 and you can access it here: https://es.infragistics.com/my-account/support-activity.
Please let me know if you have any other questions or concerns on this matter.
1. the sample I've created is a very basic sample that re-creates the issue. the original grid I'm using is a pivotal grid in my application that uses the majority of features (custom columns/editors, conditional formating, selection settings and many other abilities. I know that everything is supported by the new xamdatagrid, but for it will require a lot of work on my classes in my application.
2. I've also tried to set ActiveCell to be the first cell when row is selected (meaning, the active cell is not the long line in the 2nd column, this also does not work
I'll be happy to hear any suggested workaround or fix I can implement, even it this requires some work from my side... the alternative will be much harder...
Thanks!
WPFChart.zip
I'm attaching an example that shows this issue.
as you can see, the style, with the preview-event-handler is defined as a resource of the grid.
a code creates a new conditional format style while using the original style as the 'basedon'.
exception is thrown.
this also occurs if I try to add the preview handler via code, when trying to define the style targettype of the 'basedon' as CellControl and not ConditionalFormattingCellControl.
when using the style in ConditionalFormattingCellControl that is new and not the original style - exception occurs. looks like some internal code that does not know how to cast EventSetter from the list of Setters.
Any idea?
As long as the “style” that you are setting there is a Style with it’s TargetType set to a ConditionalFormattingCellControl, this appears to be valid. It is possible that there is a bug in this area, since the XamGrid was originally designed for Silverlight where EventSetters didn’t exist, but I have yet to reproduce the exception you are seeing with this style?
It is possible that this could have to do with a specific type of conditional formatting, and I am missing that piece. Would it be possible for you to please provide some additional information about the conditional format you are applying or perhaps even an isolated sample project that demonstrates the exception you are seeing?
I have tried your suggestion in the simple example and it did the 'trick'.
however, the original XamGrid I'm using has conditional format for this problematic column.
when trying to add the 'preview' via code, I'm getting an exception when running it
style.Setters.Add(new EventSetter(ConditionalFormattingCellControl.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(PreviewMouseDown)));
am I missing something? or this is not possible to add event-setter to conditional formatting cell?
Unable to cast object of type 'System.Windows.EventSetter' to type 'System.Windows.Setter'.
at Infragistics.Controls.Grids.ConditionalFormattingCell.ConditionalFormattingCellBindingConverter.MergeSettersIntoSingleStyle(List`1 setters, Style basedOnStyle, Boolean& controlTemplateSet, Boolean& needApplyStyle, ControlTemplate& controlTemplate) at Infragistics.Controls.Grids.ConditionalFormattingCell.ConditionalFormattingCellBindingConverter.Convert(Object value, Type targetType, Object parameter, CultureInfo culture) at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange) at System.Windows.Data.BindingExpression.Activate(Object item) at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt) at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance) at MS.Internal.Data.DataBindEngine.Run(Object arg) at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent() at System.Windows.ContextLayoutManager.UpdateLayout() at Infragistics.Controls.XamZoombar.UpdateElementPositions() at Infragistics.Controls.XamZoombar.HorizontalRootCanvas_SizeChanged(Object sender, SizeChangedEventArgs e) 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.FrameworkElement.OnRenderSizeChanged(SizeChangedInfo sizeInfo) at System.Windows.ContextLayoutManager.fireSizeChangedEvents() at System.Windows.ContextLayoutManager.UpdateLayout() at Infragistics.Windows.DockManager.ContentPane.ActivateInternalImpl(Boolean force, Boolean bringIntoView, Boolean restoreMinimizedToolWindow) at Infragistics.Windows.DockManager.ContentPane.ActivateInternal(Boolean force, Boolean bringIntoView, Boolean restoreMinimizedToolWindow) at Infragistics.Windows.DockManager.ContentPane.Activate() at LogDog.Interactions.SessionsController.DisplayAnalysisOutput(Object sender, RunWorkerCompletedEventArgs e) in D:\Visual Studio Projects\Production\Tsm\LogPad\LogDog\Interactions\SessionsController.cs:line 470 at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(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 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(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.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at LogDog.App.Main()
I was also able to recreate the issue with a simple sample, and I attached it to development ID 273165 mentioned above so that our development teams will have it as well.
I have been investigating into a workaround, and the best thing I can recommend is to prevent the very large column from activating outright at the moment, as this will prevent the horizontal scrollbar from moving. In order to do this, you can write a Style for CellControl and use an EventSetter to hook the PreviewMouseDown event and mark it handled. The CellControl sender of that event will have a reference to the Cell and the Cell to the Row, which you can then mark selected.
Where you may run into issues here is if you want to allow editing of the large column, though. You may need to place the cell into edit mode programmatically, but this also will likely result in the scrolling issue because a cell needs to be active to go into edit mode, and the activation of the cell is what is scrolling the grid in this case.
I am attaching a sample project with a simple proposed workaround that handles the PreviewMouseDown event on CellControl and just marks the Row selected instead of allowing activation of the cells.
XamGridLongColumnScrollingTest.zip