dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

FlyoutPage and your IsPresented property Fail to Link #9055

Open Ruben1204 opened 2 years ago

Ruben1204 commented 2 years ago

Description

when trying to link the ispresented property of the flyoutpage to a viewmodel the property does not take the changes with the binding for example:

this is the view from FlyoutPage

<FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Peleg.App.View"
             xmlns:VMbinding="clr-namespace:Prueba.App.ViewModel"
             x:Class="Prueba.App.View.SettingFlyoutPage"
             IsPresented="{Binding FlyoutState, Mode=TwoWay}"
             Title="SettingFlyoutPage">
    <FlyoutPage.BindingContext>
        <VMbinding:HomePageViewModel/> <!--En este codigo enlazamos el view model por medio de una variable para luego usarla como acceso a sus propiedades-->
    </FlyoutPage.BindingContext>
    <FlyoutPage.Flyout>
        <local:SidebarPage x:Name="flyoutPage"/>
    </FlyoutPage.Flyout>
    <FlyoutPage.Detail>
        <NavigationPage>
            <x:Arguments>
                <local:HomeDetailPage/>
            </x:Arguments>
        </NavigationPage>
    </FlyoutPage.Detail>
</FlyoutPage>

this is my ViewModel

namespace Prueba.App.ViewModel
{
    public class HomePageViewModel : BaseViewModel
    {

        bool flyoutstate;

        public bool FlyoutState
        {
            get { return flyoutstate; }
            set {
                if (flyoutstate==value)
                    { return; }
                    flyoutstate = value;
                    OnPropertyChanged();
                }
        }

 public ICommand CommandBtnSearch { private set; get; }

 public HomePageViewModel()
        {
            CommandBtnSearch = new Command(
                execute:() =>
                {
                    FlyoutState=true;
                    OnPropertyChanged();

                },
                canExecute:() =>
                {
                    return !FlyoutState;
                });
           }

from here I link the command property

 <ImageButton.GestureRecognizers>
                        <TapGestureRecognizer Command="{Binding CommandBtnSearch}"/>                        
</ImageButton.GestureRecognizers>

however, the change does not occur in the property.

Steps to Reproduce

  1. I create the view where I will link the command
  2. in the ViewModel i create the traditional property and i i create the command then at the constructor i initialize the command and run it
  3. link the ispresented property of the floyoutpage with the property that changes in the viewmodel

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11, windows sdk 10

Did you find any workaround?

Not

Relevant log output

No response

ghost commented 11 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.