Created
August 14, 2019 11:20
-
-
Save nord-/012a3f0a9d82ffbb4efaeb5d9c635346 to your computer and use it in GitHub Desktop.
ContentPage base class for Xamarin Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
using Xamarin.Forms; | |
namespace ChargeNode | |
{ | |
public class ContentPageBase<T> : ContentPage where T : PageViewModelBase | |
{ | |
protected T PageViewModel | |
{ | |
get => BindingContext as T; | |
set => BindingContext = value; | |
} | |
} | |
public abstract class PageViewModelBase : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) | |
{ | |
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment