IndexOutOfRangeException occurs in some situations when updating the ItemsSource collection of RadDataGrid. In order to reproduce the issue, the ItemsSource collection should be cleared by calling its Clear method. When you add a specific number of items after that the error occurs. The number of added items depends on the viewport's height.
To work this around, instead of calling the Clear() method of the ItemsSource collection, remove the items one by one.
var collection = (ObservableCollection<MyModel>)this.dg.ItemsSource;
while (collection.Count > 0)
{
collection.RemoveAt(collection.Count - 1);
}
The click actions (like cell selection and sorting) stop working when RadDataGrid is hosted in a RadTabControl or TabView. To reproduce this, you should select the tab item with the data grid, then select another tab, and select back the tab with the data grid. This prevents the hit testing in the RadDataGrid element.
The issue occurs because the hit test service used in the RadDataGrid implementation. The hit test service relies on the IsLoaded property of RadDataGrid (inherited from RadControl). The property is set in the Loaded and Unloaded events. However, when switching tabs, the Unloaded event is invoked on deselection, but on second selection of the same tab, the Loaded event is never called again, thus IsLoaded is false.
To work this around, you can subscribe to the PreviewSelectionChanged event of RadTabControl and manually update the internal isLoaded field of the data grid.
private void RadTabControl_PreviewSelectionChanged(object sender, Telerik.UI.Xaml.Controls.RadSelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
var gridView = ((RadTabItem)e.AddedItems[0]).Content as RadDataGrid;
var isLoadedField = typeof(RadControl).GetField("isLoaded", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
isLoadedField.SetValue(gridView, true);
}
}
This is the same feature as the "FilterRow" FilteringMode setting of RadGridView for WPF.
The scrolling in RadChat feels incosistent and not smooth when having messages with different heights.
To work around this you can modify the ControlTemplate of ChatMessageList in order to set the Background property of the ScrollViewer element to a value different than null. For example, Transparent.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="ms-appx:///Telerik.WinUI.Controls/Themes/Generic.xaml"/>
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
<Style TargetType="chat:ChatMessageList" BasedOn="{StaticResource ChatMessageListStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="chat:ChatMessageList">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<!--The background of the Scrollviewer is set here-->
<ScrollViewer x:Name="PART_ScrollViewer"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled"
BorderThickness="0"
Background="Transparent">
<ItemsPresenter Margin="{TemplateBinding Padding}" />
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
The list with the RadChat messages disappears when the ImageSource of ImageCardMessage is assigned after the control is loaded.
To work this around, you can pre-set the ImageSource of the image cards using a placeholder image.
Hi Support
I'm using RadDataGrid on several pages in my application. There a pages where the scrollbar does not appear. On some pages it works.
The structure of the pages is similar. What are your suggestions to look for.
Regards,
Hans
Hello, I tried to implement the sample application from your docs. (https://docs.telerik.com/devtools/winui/controls/raddatagrid/row-details)
But it seems to be not working, the detail area is not displayed completely. Only one column.
I have a similar behavior on another application.
Details: