An example with CollectionView:
<CollectionView ItemsSource="{Binding EmptyMonkeys}"
EmptyView="No items to display" />
Hi Team,
In the current RadListView implementation, the RadListView will start with all the groups expanded. The only way to have any form of preference is to programmatically interact with the Dataview after-the-fact https://docs.telerik.com/devtools/maui/controls/listview/grouping/expand-collapse
This is problematic because I need to take a wild guess as to how long it takes for the data to load in the RadListView.Loaded event and then manually collapse them.
Even if I time this perfectly... this results in visual flash for the user because the ListView starts expanded and immediately collapses.
A better approach that I am requesting a feature for is to have a property available for the RadListView that sets this value ahead of time.
For example, you could add it as a BindableProperty on the GroupDescriptorBase class.
// THE OFFICIAL BASE CLASS
public abstract class GroupDescriptorBase : OrderedDescriptorBase, IKeyLookup
{
public object GetKey(object item) => this.GetKeyCore(item);
protected abstract object GetKeyCore(object item);
protected virtual object GetDefaultKey(object item) => item;
// SUGGESTED IMPROVEMENT
public bool IsExpanded
{
get => (bool)GetValue(IsExpandedProperty);
set => SetValue(IsExpandedProperty, value);
}
public static readonly BindableProperty IsExpandedProperty = BindableProperty.Create(
nameof(IsExpanded),
typeof(bool),
typeof(GroupDescriptorBase),
true, // the default right now is true... do not change that because no breaking changes
propertyChanged: OnIsExpandedChanged);
static void OnIsExpandedChanged(BindableObject bindable, object oldValue, object newValue)
{
if (bindable is GroupDescriptorBase self)
{
if (!(bool)newValue)
{
// PLEASE DO NOT START WITH GROUPS EXPANDED
}
}
}
}
Or you could even put it a little lower, next to the BindableProperty SortOrder:
Thank you for your consideration,
Jian
on the GroupDefinition is to have a IsExap
Since migrating to MAUI .NET8 GA 8.0.3 (and Telerik 6.5) - on iOS the RadListView keeps repeatedly triggering the defined LoadOnDemand command to get more items even though list has not been scrolled by user.
the behavior is valid for the command, event and collection and when automatic load on demand mode is used.
When using manual mode, it works as expected.
The exception is easily reproducible in SDK Browser on iOS and MacCatalyst. Start the LoadOnDemandCommand or LoadOnDemandEvent example to see the exception. The LoadOnDemandCollection seems to work correctly, however.
The ListViewLoadOnDemandCollection can be used instead of the command/event as a temporary workaround, until the bug gets fixed.
When using .net maui multi-window and adding RadListView the following exception occurs on some mac machines:
Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController!'
I used RadListView in a Grid, Grid has ColumnSpacing,
for example:
<Grid
RowSpacing="1"
ColumnSpacing="1"
WidthRequest="305"
HeightRequest="303"
BackgroundColor="#FF454545">
<Grid.RowDefinitions>
<RowDefinition Height="36"/>
<RowDefinition Height="28"/>
<RowDefinition Height="82"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="152"/>
<ColumnDefinition Width="152"/>
</Grid.ColumnDefinitions>
<telerik:RadListView x:Name="listView" Grid.Row="5" Grid.ColumnSpan="2" WidthRequest="305">
<telerik:RadListView.ItemTemplate>
<DataTemplate>
<telerik:ListViewTemplateCell>
<telerik:ListViewTemplateCell.View>
<Grid BackgroundColor="Gray">
<Label Margin="10" Text="{Binding Name}" />
</Grid>
</telerik:ListViewTemplateCell.View>
</telerik:ListViewTemplateCell>
</DataTemplate>
</telerik:RadListView.ItemTemplate>
</telerik:RadListView>
</Grid>
I found the RadListView.Width is 304(ColumnDefinition plus), not 305.
Currently the LoadOnDemandCollection accepts a callback of the following format in the constructor:
public LoadOnDemandCollection(Func<CancellationToken, IEnumerable> action)
It is a very common scenario to populate the items asynchronously. In its current form the collection would require blocking the current thread to populate the results:
ItemsSource = new ListViewLoadOnDemandCollection((cancelationToken) =>
{
var result = new List<ItemsModel>();
try
{
var items = dataService.GetItemsAsync().Result;
// TODO: Handle the result.
return result;
}
catch (Exception e)
{
// TODO: Handle the exception.
return null;
}
});
This is not desired, as using Task.Result blocks the current thread and is considered an anti-pattern, in general.
A better approach would be to add a second overload of the constructor, allowing asynchronous calls:
public LoadOnDemandCollection(Func<CancellationToken, Task<IEnumerable>> action)
This way we can use async and await in the callback instead:
ItemsSource = new ListViewLoadOnDemandCollection(async (cancelationToken) =>
{
var result = new List<ItemsModel>();
try
{
var items = await dataService.GetItemsAsync();
// TODO: Handle the result.
return result;
}
catch (Exception e)
{
// TODO: Handle the exception.
return null;
}
});
According to my tests, the first blocking approach is not a problem, as the ListViewLoadOnDemandCollection starts a thread internally. That behavior is not obvious however, and using Task.Result is somewhat counterintuitive, so the second approach is much better from the user's perspective.