The use of x:Bind
requires the binding path to be rooted in the View.
To use the DataContext, you'll need make it available typed through the view, like this:
public partial class MyControl : INotifyPropertyChanged
{
#if !HAS_UNO
// Uno already defines this event (it will be removed
// in the future to be aligned properly with WinUI)
public event PropertyChangedEventHandler PropertyChanged;
#endif
public MainPage()
{
this.InitializeComponent();
DataContextChanged +=
(s, e) => PropertyChanged?.Invoke(
this,
new PropertyChangedEventArgs(nameof(ViewModel)));
}
public MyViewModel ViewModel => DataContext as MyViewModel;
}