Xamarin.forms: [Bug] 4.6-pre4 Expander.ForceUpdateSizeCommand is never executed

Created on 15 Apr 2020  路  5Comments  路  Source: xamarin/Xamarin.Forms

Description

Xamarin.Forms 4.6-pre4 introduces the Expander. It has a ForceUpdateSizeCommand property, which invokes the ForceUpdateSize public method.

However, binding the ForceUpdateSizeCommand to an ICommand is pointless as the Expander class never calls ForceUpdateSizeCommand.Execute().

Basic Information

  • Version with issue: 4.6-pre4
expander unverified bug

Most helpful comment

@AndreiMisiukevich Got it, thanks!

All 5 comments

@AndreiMisiukevich Are you aware of this? Thanks!

@samhouts @davidbritch Hi.

This command's bindable property has OneWayToSource binding strategy.
It means that BindingContext should invoke this.

Please look at this
https://github.com/xamarin/Xamarin.Forms/blob/8a458aebef77d6a7b2614cfdb1b3aaadd3396015/Xamarin.Forms.Core/Expander.cs#L60

var expander = new Expander();
expander.SetBinding(Expander.ForceUpdateSizeCommandProperty, "UpdateSizeCommand");
expander.BindingContext = new ViewModel();
...

class ViewModel {
    public ICommand UpdateSizeCommand { get; set; }

    void DoSomething() {
        ....
        UpdateSizeCommand?.Execute(null);
    }
}

Hi @AndreiMisiukevich

Thanks for the explanation. I'm just struggling to envisage a useful scenario for a view model executing its own ICommand. Any thoughts?

Hi @AndreiMisiukevich

Thanks for the explanation. I'm just struggling to envisage a useful scenario for a view model executing its own ICommand. Any thoughts?

e.g. you expand the expander control and at the bottom of your content you have a "show more" button that should expand it more.

@AndreiMisiukevich Got it, thanks!

Was this page helpful?
0 / 5 - 0 ratings