Ejemplo n.º 1
0
        private static void IsFocusedPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var view = bindable.AsType <View>();

            view.Focused   -= ViewOnFocused;
            view.Focused   += ViewOnFocused;
            view.Unfocused -= ViewOnFocused;
            view.Unfocused += ViewOnFocused;

            if (oldValue == newValue || newValue == null)
            {
                return;
            }

            bool isFocused;

            if (bool.TryParse(newValue.ToString(), out isFocused) == false)
            {
                return;
            }

            if (isFocused)
            {
                view.Focus();
            }
            else
            {
                view.Unfocus();
            }
        }
Ejemplo n.º 2
0
        private static async void AddTappedCommand(BindableObject bindable)
        {
            var view = bindable.AsType <View>();

            command = GetTappedCommand(bindable);
            if (view != null && command != null)
            {
                view.AddTappedCommand(command, GetTappedCommandParameter(bindable));
            }
        }
Ejemplo n.º 3
0
        private static void ItemTappedChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var listView = bindable.AsType <ListView>();

            listView.ItemTapped += async(sender, args) =>
            {
                (newValue as ICommand)?.Execute(null);

                await Task.Delay(TimeSpan.FromSeconds(2));

                // Clear selection
                listView.SelectedItem = null;
            };
        }
Ejemplo n.º 4
0
        private static void IsAnimatedChanged(BindableObject bindable, object oldValue, object newValue)
        {
            // Add animation to the view
            var view = bindable.AsType <View>();

            view?.GestureRecognizers.Add(
                new TapGestureRecognizer
            {
                Command = new Command(
                    async() =>
                {
                    // Scale up and down
                    await view.ScaleTo(1.2, 50, Easing.CubicOut);
                    await view.ScaleTo(1, 50, Easing.CubicIn);
                })
            });
        }