コード例 #1
0
        protected override void OnElementChanged(ElementChangedEventArgs <ContentView> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null && e.OldElement == null)
            {
                CorneredContentView corneredContentView = (this.Element as CorneredContentView);

                if (corneredContentView.Content == null)
                {
                    corneredContentView.Content = new Grid();
                }

                this.Validate(corneredContentView);

                this.SetBackground(this._drawable = new CorneredContentViewDrawable(corneredContentView, this.Context.ToPixels));

                this.SetupShadow(corneredContentView);
            }
        }
コード例 #2
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            CorneredContentView corneredContentView = this.Element as CorneredContentView;

            this.Validate(corneredContentView);

            base.OnElementPropertyChanged(sender, e);
            switch (e.PropertyName)
            {
            case nameof(VisualElement.BackgroundColor):
            {
                this._drawable.Dispose();
                this.SetBackground(this._drawable = new CorneredContentViewDrawable(corneredContentView, this.Context.ToPixels));
                break;
            }

            case nameof(CorneredContentView.CornerRadius):
            {
                this.Invalidate();
                this.SetupShadow(corneredContentView);
                break;
            }

            case nameof(CorneredContentView.BorderColor):
            case nameof(CorneredContentView.BorderThickness):
            {
                this.Invalidate();
                break;
            }

            case nameof(CorneredContentView.HasShadow):
            {
                this.SetupShadow(corneredContentView);
                break;
            }
            }
        }