How do I display a ToolbarItem disabled?

MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

I now have the need to display some ToolbarItems in a disabled state. The icons (no text) should be visible, but greyed out.

Currently I'm mostly interested in an iOS solution. My app is not released on the other platforms yet.

In my AppDelegate I set UIApplication.SharedApplication.KeyWindow.TintColor so that all Titles and ToolbarItems are tinted. So even if I change the image to a disabled one, because of this automatic tinting, the color of the image is replaced by the TintColor for all icons.

Answers

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    It was actually quite easy when you know, how to do it.

    I searched for the native UIBarButtonItem in the iOS project and set its Enabled property. iOS is clever enough to show a disabled button greyed out.

        public void SetEnabled(ToolbarItem button, bool enabled)
        {
            var barButton = Utils.GetNativeBarButton(button);
            if (barButton != null)
                barButton.Enabled = enabled;
        }
    

    I already posted the code for GetNativeBarButton in this post.

Sign In or Register to comment.