I'm experimenting with creating a simple xaml appilcation using C++/WinRT.
I come from a WPF background where it is pretty common to have a base class that implements INotifyPropertyChanged and have other classes inherit from it.
When I try to do the same with C++-WinRT I fail with an error
error MIDL4006: [msg]A runtime class can derive only from a composable runtime class.
Here is the rest of the relevant code for reference:
ObservableObject.idl:
namespace Example
{
runtimeclass ObservableObject : Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.Data.INotifyPropertyChanged
{
ObservableObject();
}
}
MainViewModel.idl:
import "ObservableObject.idl";
namespace Example
{
runtimeclass MainViewModel : ObservableObject
{
MainViewModel();
Int32 MyProperty;
}
}
So what exactly is a composable runtime class? Is there a way to achieve this with C++/WinRT? I really don't want to repeat the INotifyPropertyChanged implementation each time I define a new bindable class.