public static string SetAccessibilityLabel(this UIBarItem Control, Element Element, string _defaultAccessibilityLabel = null)
        {
            if (Element == null || Control == null)
            {
                return(_defaultAccessibilityLabel);
            }

            if (_defaultAccessibilityLabel == null)
            {
                _defaultAccessibilityLabel = Control.AccessibilityLabel;
            }

            Control.AccessibilityLabel = (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityLabel;

            return(_defaultAccessibilityLabel);
        }
        public static string SetAccessibilityHint(this UIBarItem Control, Element Element, string _defaultAccessibilityHint = null)
        {
            if (Element == null || Control == null)
            {
                return(_defaultAccessibilityHint);
            }

            if (_defaultAccessibilityHint == null)
            {
                _defaultAccessibilityHint = Control.AccessibilityHint;
            }

            Control.AccessibilityHint = (string)Element.GetValue(AutomationProperties.HelpTextProperty) ?? _defaultAccessibilityHint;

            return(_defaultAccessibilityHint);
        }
        private static void WireUpEnabledToCanExecute(ToolBarButton button, UIBarItem uiButton)
        {
            if (button.Command != null)
                button.Command.CanExecuteChanged += (s, e) =>
                        uiButton.InvokeOnMainThread(() =>
                            {
                                var enabled = button.Command.CanExecute(button.CommandParameter);

                                if (uiButton.Enabled == enabled) return;

                                uiButton.Enabled = enabled;


                                if (uiButton.Image != null)
                                    uiButton.Image = ImageHelper.AdjustOpacity(uiButton.Image, enabled ? 1 : 0.5f);
                            });

            uiButton.Enabled = button.Command == null || button.Command.CanExecute(button.CommandParameter);

            if (!uiButton.Enabled && uiButton.Image != null)
                uiButton.Image = ImageHelper.AdjustOpacity(uiButton.Image, 0.5f);
        }
 private static async void SetImage(UIBarItem uiButton, ImageSource source)
 {
     uiButton.Image = await source.GetImageAsync();
 }