Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to use ExportRenderer for CarouselView in UWP

$
0
0

Hey, I got the error
"no suitable method found to override" in UWP Class

Shared Class

using Xamarin.Forms;
namespace TestProject
{ 
    public class MyCarouselView : CarouselView
    {  
        public int NewPosition { get; private set; }

        public MyCarouselView(int newPosition)
        {
            Position = newPosition;
        }

    }
}

UWP Class

using TestProject;
using TestProject.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;


[assembly: ExportRenderer(typeof(MyCarouselView), typeof(CarouselView_UWP))]
namespace TestProject.UWP
{
    public class CarouselView_UWP : CarouselViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<MyCarouselView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                e.NewElement.Position = e.NewElement.NewPosition;
            }
        }

    }
}

ViewModel

      int currentView = Convert.ToInt32(viewIndex);
      var newInt = new MyCarouselView(currentView);

Reference

https://forums.xamarin.com/discussion/56550/custom-renderer-and-parameters


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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