简体   繁体   中英

WinRt : twoway binding for Appbar does not work

I have a very Strange problem. As per my requirement, i need to open the top appbar on a botton click(command), the button is place at the top right corner of the Screen so when the appbar will open it will cover the button area. i am using MVVM design methodology and i have binded the "IsOpen" property to a my viewmodel.

<AppBar x:Uid="NavigationBar"  IsOpen="{Binding IsNavBarVisible, Mode=TwoWay}">
       <controls:TopAppNavBarUserControl />
    </AppBar> 

when i tap the button, the IsNavBarVisible property is set to true and my appbar opens.Them problem occurs when i tap on any other part of the screen to close the appbar, the appbar closes but my property does not set to "false" so the next time i tap the button it doesnot open the appbar as the binding property is already "true". i have used the "twoway" binding here but for some unknown reason, it doesnt seam to work A solution cloud be implementing the "Closed" event of the app bar but i dont want to goto my code behind. Suggestions are welcome.

As per MSDN :

Note : Binding to the IsOpen property doesn't have the expected results because the PropertyChanged notification doesn't occur when the property is set.

So you have to work around this problem. The first thing that comes to mind would indeed be the event. Or you could create a derived AppBar and implement PropertyChanged for IsOpen yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM