Wednesday, March 13, 2024
HomeiOS Development.NET Maui ListView Get Presently seen gadgets in Android and iOS

.NET Maui ListView Get Presently seen gadgets in Android and iOS


I’ve a cross platform app (iOS/Android) at present inbuilt Xamarin that should know which gadgets in an inventory view are at present seen. It’s working in Xamarin, however I can not appear to determine port it to Maui. Does such a factor not require platform particular code in Maui?

Listed below are the related android/ios items I had in Xamarin

Android:

Listing<ViewerItemViewModel> visibleItems = new Listing<ViewerItemViewModel>();
attempt
{
    var renderer = lv.GetRenderer();

    var nativeListView = renderer.View as Android.Widget.ListView;

    for (int i = 0; i < nativeListView.ChildCount; i++)
     pos >= nativeListView.Adapter.Depend)
            proceed;

        var obj = nativeListView.Adapter.GetItem(pos);

        if (obj == null)
            proceed;

        ViewerItemViewModel visibleElement = Solid<ViewerItemViewModel>(obj);

        if (visibleElement != null && !visibleItems.Accommodates(visibleElement))
            visibleItems.Add(visibleElement);
    
}
catch (Exception ex) {

}

return visibleItems;

iOS:

var visibleItems = new Listing<ViewerItemViewModel>();

var array = lv.ItemsSource.OfType<ViewerItemViewModel>();
var renderer = lv.GetRenderer();

UITableView nativeListView = (UITableView)renderer.NativeView;

NSIndexPath[] index = nativeListView.IndexPathsForVisibleRows;

if (index != null)
    for (int i = 0; i < index.Size; i++)
        if (index[i].Row >= 0 && index[i].Row < array.Depend())
            visibleItems.Add(array.ElementAt(index[i].Row));

return visibleItems;



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments