Example #1
0
        protected void Initialize()
        {
            Flex.SetBinding(FlexLayout.DirectionProperty, new Binding(nameof(Direction), source: this));
            ButtonImage.SetBinding(Image.SourceProperty, new Binding(nameof(ImageSource), source: this));
            ButtonLabel.SetBinding(Label.FontSizeProperty, new Binding(nameof(FontSize), source: this));
            ButtonLabel.SetBinding(Label.FontFamilyProperty, new Binding(nameof(FontFamily), source: this));
            ButtonLabel.SetBinding(Label.FontAttributesProperty, new Binding(nameof(FontAttributes), source: this));
            ButtonLabel.SetBinding(Label.TextProperty, new Binding(nameof(Text), source: this));
            ButtonLabel.SetBinding(Label.TextColorProperty, new Binding(nameof(TextColor), source: this));
            ButtonLabel.SetBinding(Label.VerticalTextAlignmentProperty, new Binding(nameof(VerticalTextAlignment), source: this));
            ButtonLabel.SetBinding(Label.HorizontalTextAlignmentProperty, new Binding(nameof(HorizontalTextAlignment), source: this));

            this.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = new Command(() =>
                {
                    this.Tapped?.Invoke(this, EventArgs.Empty);

                    if (Command != null)
                    {
                        if (Command.CanExecute(CommandParameter))
                        {
                            Command.Execute(CommandParameter);
                        }
                    }
                }),
            });
        }