Search
Filters
Blog options
Close

Xamarin Forms - TableView Custom Renderers

Xamarin Forms - TableView Custom Renderers

This is a place where I plan to store all of my custom TableView renderers for Xamarin forms. If you have any that you'd like to share, please feel free to post them in the comments section.

Removes Scrolling

iOS:


using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using UIKit;
using CoreGraphics; 

[assembly: ExportRenderer(typeof(NoScrollTableView),
    typeof(MyApp.iOS.NoScrollTableViewRenderer))]

namespace MyApp.iOS
{
	public class NoScrollTableViewRenderer : TableViewRenderer
	{
		public override void LayoutSubviews()
		{
			base.LayoutSubviews();
			var tableView = Control as UITableView;
			tableView.ScrollEnabled = false;

		}
 
	}
}

Android:


using Android.Views;
using Android.Widget;  
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(NoScrollTableView), typeof(NoScrollTableViewRenderer))]
namespace MyApp.Drioid
{
	public class NoScrollTableViewRenderer : TableViewRenderer
	{ 
		public override bool DispatchTouchEvent(Android.Views.MotionEvent e)
		{ 
			if (e.Action == MotionEventActions.Move)
				return true;
			
			return base.DispatchTouchEvent(e);
		} 
	}
}