xamarin Button inside fragment return null exception <p>I'm new in developing mobile application using xamarin, and I'm having problems in adding functions in buttons inside ViewPager. It always return null exception on Button.click. Can someone help. Thanks in advance :)</p> <p>Here's my code ~</p> <pre><code>namespace SlidingTabLayoutTutorial { public class SlidingTabsFragment : Fragment { private SlidingTabScrollView mSlidingTabScrollView; private ViewPager mViewPager; public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.Inflate(Resource.Layout.fragment_sample, container, false); Button btn = view.FindViewById&lt;Button&gt;(Resource.Id.button1); btn.Click += btn_Click; return view; } void btn_Click(object sender, EventArgs e) { throw new NotImplementedException(); } public override void OnViewCreated(View view, Bundle savedInstanceState) { mSlidingTabScrollView = view.FindViewById&lt;SlidingTabScrollView&gt;(Resource.Id.sliding_tabs); mViewPager = view.FindViewById&lt;ViewPager&gt;(Resource.Id.viewpager); mViewPager.Adapter = new SamplePagerAdapter(); mSlidingTabScrollView.ViewPager = mViewPager; } public class SamplePagerAdapter : PagerAdapter { List&lt;string&gt; items = new List&lt;string&gt;(); public SamplePagerAdapter() : base() { items.Add("Profile"); items.Add("Reservation"); items.Add("Notifications"); } public override int Count { get { return items.Count; } } public override bool IsViewFromObject(View view, Java.Lang.Object obj) { return view == obj; } public override Java.Lang.Object InstantiateItem(ViewGroup container, int position) { if (position == 0) { View view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.profileLayout, container, false); container.AddView(view); return view; } else { return position; } } public string GetHeaderTitle(int position) { return items[position]; } public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object obj) { container.RemoveView((View)obj); } } } } </code></pre>