Exemple #1
0
        protected override void Init()
        {
            var statusLabel = new Label
            {
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                FontSize          = 40,
                Text = "EFFECT IS NOT ATTACHED"
            };

            _effect = new AttachedStateEffect();

            _statusFrame = new Frame
            {
                BackgroundColor   = Color.Red,
                Padding           = 15,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Content           = statusLabel
            };

            _effect.StateChanged += (sender, e) =>
            {
                statusLabel.Text = _effect.State == AttachedStateEffect.AttachedState.Attached
                                        ? SuccessMessage
                                        : "EFFECT IS DEATTACHED";

                _statusFrame.BackgroundColor = Color.LightGreen;
            };

            Content = new StackLayout
            {
                Padding  = 50,
                Children =
                {
                    _statusFrame
                }
            };
        }
 protected override void OnAttached()
 {
     MyEffect = Element.Effects.OfType <AttachedStateEffect>().First();
     MyEffect.Attached(Element);
 }