If you want to be notified when some dependency property of a control changes, for example, UIElement::Visibility, you can do the following trick. First declare you own dependency property of the same type in some class:
public ref class MyListener
{
public:
static property Windows::UI::Xaml::DependencyProperty ^ BoundVisibilityProperty
{
Windows::UI::Xaml::DependencyProperty ^ get() { return boundVisibilityProperty; }
}
property Windows::UI::Xaml::Visibility BoundVisibility
{
Windows::UI::Xaml::Visibility get() { return safe_cast<Windows::UI::Xaml::Visibility>(GetValue(boundVisibilityProperty)); }
void set(Windows::UI::Xaml::Visibility value) { SetValue(boundVisibilityProperty, value); }
}
static Windows::UI::Xaml::DependencyProperty ^ boundVisibilityProperty;
static void OnBoundVisibilityChanged(DependencyObject^ d, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
};
