protected override IEnumerable <IDisposable> Initialize() { // Content _appBarButtonWrapper = new AppBarButtonWrapper(); if (Element.Content is FrameworkElement content && content.Visibility == Visibility.Visible) { var elementsParent = Element.Parent; _appBarButtonWrapper.SetParent(elementsParent); } yield return(Disposable.Create(() => _appBarButtonWrapper = null)); yield return(Element.RegisterDisposableNestedPropertyChangedCallback( (s, e) => Invalidate(), new[] { AppBarButton.LabelProperty }, new[] { AppBarButton.IconProperty }, new[] { AppBarButton.IconProperty, BitmapIcon.UriSourceProperty }, new[] { AppBarButton.ContentProperty }, new[] { AppBarButton.ContentProperty, FrameworkElement.VisibilityProperty }, new[] { AppBarButton.OpacityProperty }, new[] { AppBarButton.ForegroundProperty }, new[] { AppBarButton.ForegroundProperty, SolidColorBrush.ColorProperty }, new[] { AppBarButton.ForegroundProperty, SolidColorBrush.OpacityProperty }, new[] { AppBarButton.VisibilityProperty }, new[] { AppBarButton.IsEnabledProperty }, new[] { AppBarButton.IsInOverflowProperty } )); Native.Clicked += OnNativeClicked; yield return(Disposable.Create(() => { Native.Clicked -= OnNativeClicked; })); }