简体   繁体   中英

how to disable Application Bar Icon Button while processing other functions in windows phone application

reference

I have a code like below

private void btnSave_Click(object sender, EventArgs e){

(ApplicationBar.Buttons[0] as ApplicationBarIconButton).IsEnabled = false;

if (backstatus == false)
    {
    backstatus = true;
            myPopup.IsOpen = true;
            Dispatcher.BeginInvoke(delegate()
            {
        // some big code which take five minits to execute
    }
} }

At the time of taping that button it is in enable mode. It will disable after execute hole the function.

But i need to disable it while processing other functions.

You can use MVVM way and bind commands from your viewmodel to the applicationbar buttons. Or else, use await async for the long process instead of dispatcher.begininvoke()

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