Hi Team,
Please expose the ScrollViewer, or expose a method on the RadListView that allows the developer to set a Y device-independent vertical position. Setting the Y value will trigger the internal/native scrollview to go to that position without any special animations or manipulation. Just a pure position set.
I need to be able to programmatically scroll to a specific position in the list. Yes, I am aware of the ScrollToItem methods, however that will not work in my case as I explicitly need the Y position (for acceleration and manipulation of the exact position).
As an example, here's how I am currently doing it for a ScrollView:
private async Task AutoScrollAsync()
{
while (!(this.ScrollVelocity == 0 || this.ScrollVelocity > 0 && this.IsScrolledToBottom() || this.ScrollVelocity < 0 && this.IsScrolledToTop()))
{
await this.scrollView.ScrollToAsync(0, this.CalculateNextScrollY(), false);
await Task.Delay(ScrollDelay);
}
this.StopScrolling();
}
I am hoping to be able to do the same thing for the RadListView.
Thank you,
Aaron
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.
The bug occurs on Android when removing an item from a group and using sticky group headers.
if you start to reorder an item, and then drop it in the same position that it already had (i.e. abort/cancel the reorder) , the gray color is now stuck. The issue happens only on Android.
When the VerticalItemSpacing is greater than 1 and an ItemStyle with a Border is defined the background of the item is overlapping the border.
<telerik:RadListView Grid.Column="0" ItemsSource="{Binding Source}">
<telerik:RadListView.LayoutDefinition>
<telerik:ListViewLinearLayout Orientation="Vertical" VerticalItemSpacing="4" />
</telerik:RadListView.LayoutDefinition>
<telerik:RadListView.ItemStyle>
<telerik:ListViewItemStyle
BackgroundColor="Green"
BorderColor="LightGreen"
BorderLocation="All"
BorderWidth="1" />
</telerik:RadListView.ItemStyle>
<telerik:RadListView.SelectedItemStyle>
<telerik:ListViewItemStyle
BackgroundColor="Orange"
BorderColor="OrangeRed"
BorderLocation="All"
BorderWidth="1" />
</telerik:RadListView.SelectedItemStyle>
<telerik:RadListView.PressedItemStyle>
<telerik:ListViewItemStyle
BackgroundColor="Orange"
BorderColor="OrangeRed"
BorderLocation="All"
BorderWidth="1" />
</telerik:RadListView.PressedItemStyle>
<telerik:RadListView.ItemTemplate>
<DataTemplate x:DataType="local:SourceItem">
<telerik:ListViewTemplateCell>
<telerik:ListViewTemplateCell.View>
<Grid>
<Label Margin="10" Text="{Binding Name}" />
</Grid>
</telerik:ListViewTemplateCell.View>
</telerik:ListViewTemplateCell>
</DataTemplate>
</telerik:RadListView.ItemTemplate>
</telerik:RadListView>
Having ContentViews for left and right item swipe
The ListView crashes
When setting margin to the elements in the template, the margin is not respected
I have a collection of items, and one of the properties notifies changes to the UI. ("BooleanProperty") I also bind to the SelectedItem property on the list view to toggle this bool property to true or false.
I have another property "Description" that I am sorting by. When sorting the ListView and select an item, the items with the same value are reordered.
There is a slow performance when scrolling, expand/collapse items when the ListView Groups are sticky and GroupHeaderTemplate is used.
Workaround:
1. Set IsGroupHeaderStickty to false.
or
2.. Use the default group header template
Android: when tapping on load on demand template the data is not loaded.
If you use the LoadOnDemandCommand you can bind the command to the button inside the template.
On WinUI there is an exception runtime
Workaround:
Use automatic load on demand mode or bind the command to the template
public class City
{
public string Name { get; set; }
public string Country { get; set; }
public Image CountryFlag { get; set; }
}