One of the following two exceptions occur when the BindingOperations.EnableCollectionSynchronization() is used with the ItemsSource of RadTreeListView:
When using the EnableCollectionSynchronization, the corresponding items control should allow updates of the ItemsSource collection on different threads. This is valid if the requirements to use the EnableCollectionSynchronization method are met.
The exception stack traces are:
InvalidOperationException
at System.ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion() in /_/src/libraries/System.Private.CoreLib/src/System/ThrowHelper.cs:line 432
at System.Collections.Generic.List`1.Enumerator.MoveNext() in /_/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs:line 1130
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at Telerik.Windows.Data.EnumerableExtensions.<SelectRecursive>d__15`1.MoveNext()
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at Telerik.Windows.Data.HierarchicalCollectionViewBase.PopulateInternalList(IQueryable view)
at Telerik.Windows.Data.QueryableCollectionView.get_InternalList()
at Telerik.Windows.Data.HierarchicalCollectionViewBase.get_InternalCount()
at Telerik.Windows.Data.DataItemCollection.get_Item(Int32 index)
at Telerik.Windows.Controls.GridView.Rows.GetRowItemsAtRange(Int32 startIndex, Int32 endIndex)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize)
at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)
NullReferenceException at Telerik.Windows.Data.QueryableCollectionView.InternalGetItemAt(Int32 index) in Telerik.Windows.Data\QueryableCollectionView.cs:line 3081 at Telerik.Windows.Controls.GridView.Rows.GetRowItemsAtRange(Int32 startIndex, Int32 endIndex) at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.RealizeRows(Int32 startIndex, Int32 endIndex, Double& verticalOffset, HashSet`1& realizedRows) at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.FlatLayoutStrategy.MeasureOverride(Size availableSize) at Telerik.Windows.Controls.GridView.GridViewVirtualizingPanel.MeasureOverride(Size availableSize)
To work this around dispatch the updates of the ItemsSource collection to the main UI thread.
Dispatcher.BeginInvoke(new Action(() =>
{
// add/remove items from the source collection
}));
The horizontal scrollbar of RadTreeListView is displayed even the setup suggest that it should not be. For example, this happens if you have a single column with its Width set to * which means that the RadGridView should span in the available space without the need of displaying a horizontal scrollbar. To recreate this the RowIndicatorVisibility property should be set to Collapsed. Additional to that there should be a hierarchy and the items should be expanded.
To work this around, you can set a fixed Width for the column. If you want this to be dynamic you can calculate the width on SizeChanged of RadTreeListView
By default the AutoExpandItemsAfterFilter property of RadTreeListView is set to True, which means that when you filter the data, the parents of all found child items will be expanded automatically. However, if you call the CollapseAllHierarchyItems method this functionality stops working.
To work this around, you can reset the ItemsSource property instead of using the CollapseAllHierarchyItems.
private void RadTreeListView_Filtering(object sender, Telerik.Windows.Controls.GridView.GridViewFilteringEventArgs e)
{
var treeListView = sender as RadTreeListView;
var internalColumns = treeListView.GetType().GetProperty("InternalColumns", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(treeListView);
internalColumns.GetType().GetProperty("ColumnWidthsCalculationPending", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(internalColumns, true);
}
private void RadTreeListView_Filtered(object sender, Telerik.Windows.Controls.GridView.GridViewFilteredEventArgs e)
{
Dispatcher.BeginInvoke(new Action(() =>
{
var treeListView = sender as RadTreeListView;
var internalColumns = treeListView.GetType().GetProperty("InternalColumns", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(treeListView);
internalColumns.GetType().GetProperty("ColumnWidthsCalculationPending", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(internalColumns, false);
}), System.Windows.Threading.DispatcherPriority.Loaded);
}
If you press Ctrl+Up/Down to change the selection and currency in TreeListView, the CurrentCellChanged event is fired. However, the e.NewCell property of the event arguments is null.
To get the new cell, use the CurrentCellInfo property of RadTreeListView.
private void RadTreeListView_CurrentCellChanged(object sender, GridViewCurrentCellChangedEventArgs e)
{
var treeListView = (RadTreeListView)sender;
GridViewCellInfo currentCell = treeListView.CurrentCellInfo;
}
An exception is thrown when you try to update the items source of RadTreeListView in an async method.
The following error is observed.
InvalidOperationException: The calling thread cannot access this object because a different thread owns it
To work this around ensure that only the main UI thread updates the item source.
I am using a RadTreeListView with MaterialDesign theme in a Windows WPF application. By default the selected cell is indicated by a grey line at the bottom of the cell. I don't want an indication for the selected cell and used the advise from forum to change the style as follows:
<Style TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}">
<Setter Property="CurrentBorderBrush" Value="Transparent"/>
</Style>
This works fine.
But if changing the Windows application with Alt+Tab and then back to my application with Alt+Tab the cell selection (grey underline) is displayed.
Per the thread at "http://www.telerik.com/forums/isexpandablebinding-requires-user-interaction-with-control-to-take-effect" I have modified the IsExpandedRowBinding sample to recreate the problem. I modified the button to expand and collapse the first row. To reproduce the problem: 1. Expand the first row. 2. Scroll down so the first row is not visible but it's children are visible. 3. Press the button. The expected behavior is the first row should collapse but nothing happens. 4. Scroll up so the first row is visible. The first row collapses.
If you move an item from one level to another into the tree, the indent of the corresponding row won't get updated. This is reproducible only if the new parent of the moved item is expanded, while the operation is executed. Usually, this can be reproduced by calling the ExpandHierarchyItem() for the new parent item method just after the moving of the original item. To resolve this you can delay the expanding of the item. Note that the expanding is executed manually by calling the ExpandHierarchyItem() method. So, you can use a dispatcher with a lower DispatcherPriority to delay this. Or alternatively, you can collapse the item before expanding it (using the CollapseHierarchyItem() method).