roycornelissen/GMImagePicker.Xamarin

Change CustomDoneButtonTitle at live time

Opened this issue · 1 comments

Version: 2.5.1
Xamarin.Forms Version: 5.0.0.2012

Can I change the CustomDoneButtonTitle depending on whether I have selected an image or not? With AutoDisableDoneButton, I can only set the button to be disabled, but it will still be displayed..

I tried:

m_CurrentPicker = new GMImagePickerController(...);

m_CurrentPicker.AssetSelected += CurrentPickerOnAssetSelected;
m_CurrentPicker.AssetDeselected += CurrentPickerOnAssetSelected;

    private void CurrentPickerOnAssetSelected(object sender, SingleAssetEventArgs args)
    {
        var selectedCount = m_CurrentPicker.SelectedAssets.Count;
        m_CurrentPicker.CustomDoneButtonTitle = selectedCount > 0 ? "Done" : "";
    }

Hi! Setting the CustomDoneButtonTitle does not update the button at real time, it only initializes the buttons once during ViewDidLoad. So that CustomDoneButtonTitle is not data bound to the actual button anymore. It's probably doable by wiring some stuff up in the property setter but it's quite a refactor to do so.