Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

iOS Pull to refresh

$
0
0

I want to implement pull to refresh on a Forms project I have, but after the refresh is over, the Cells in the ListView are empty on iOS. this is what I got

<ListView x:Name="listView" Grid.Row="2" Grid.Column="0" ItemsSource="ActivityList" BackgroundColor="#D6D6D6" IsVisible="False"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <custom:CustomFrame Padding="0,5,0,0" Margin="0,10,0,0" > <StackLayout> <Label Style="{StaticResource bold}" FontSize="Large" TextColor="#c4950b" Margin="10,0,0,0" x:Name="labelName" Text="{Binding Key}" /> <local1:Carousel ActList="{Binding Value}" KeyName="{Binding Key}" /> </StackLayout> </custom:CustomFrame> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
ListView CustomRenderer
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizPass.iOS;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(ListView), typeof(NoBarListView))]
namespace BizPass.iOS
{
class NoBarListView : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Control != null)
{
var itemCount = Control.NumberOfRowsInSection(0);
System.Diagnostics.Debug.WriteLine(itemCount);
Control.ShowsHorizontalScrollIndicator = false;
Control.ShowsVerticalScrollIndicator = false;

        }
    }
}

}
`

Frame CustomRenderer
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BizPass.iOS;
using CoreGraphics;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;

[assembly: ExportRenderer(typeof(BizPass.Controls.CustomFrame), typeof(CustomFrame))]
namespace BizPass.iOS
{
class CustomFrame : FrameRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if(e.OldElement != null)
        {
            var rect = e.OldElement.Bounds.ToRectangleF();
            this.Draw(rect);
        }

        //Forces the element to be redrawn when coming into veiw. Specifically for upcoming list
        ContentMode = UIViewContentMode.Redraw;
    }

    //Method to draw the control
    public override void Draw(CGRect rect)
    {
        // Update shadow to match better material design standards of elevation
        Layer.ShadowRadius = 2.0f;
        Layer.ShadowColor = UIColor.LightGray.CGColor;
        Layer.ShadowOffset = new CGSize(2, 2);
        Layer.ShadowOpacity = 0.80f;
        Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
        Layer.MasksToBounds = false;
        base.Draw(rect);
    }
}

}

`


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>