![](/img/trans.png)
[英]how to disable Application Bar Icon Button while processing other functions in windows phone application
[英]Windows phone disable application bar button
那么,我的問題是什么? 我有一個popup
,當我打開它時,我想在我的Windows手機應用程序中禁用當前頁面。 所以我這this.IsEnabled = false;
這個this.IsEnabled = false;
但我的ApplicationBar
仍然可用。 當然我嘗試:
ApplicationBar.IsMenuEnabled = false;
我的下一個想法是做這樣的事情:
for (int i = 0; i < ApplicationBar.MenuItems.Count; i++)
{
((ApplicationBarMenuItem)ApplicationBar.Buttons[i]).IsEnabled = false;
}
但仍然沒有結果。 我確信之前已經完成了一些,你能告訴我怎么做的嗎?
應用程序欄由Buttons集合和MenuItems集合組成。 對於你的例子,你會想嘗試類似的東西
foreach (var button in ApplicationBar.Buttons)
{
((ApplicationBarIconButton) button).IsEnabled = false; // disables the button
}
ApplicationBar.IsMenuEnabled = false; // this will prevent menu from opening
如果這不起作用,您是否考慮過隱藏應用欄?
ApplicationBar.IsVisible = false;
這個怎么樣
((ApplicationBarIconButton)this.ApplicationBar.Buttons[1]).IsEnabled = true;
其中[1]是要啟用/禁用的按鈕的索引
我知道這是事實,因為我有在Windows Phone 8應用程序中使用它的代碼
你能發一些代碼給我們看看嗎
不幸的是,根據這篇文章,有一個錯誤,這意味着在關閉並重新打開菜單之前,設置ApplicationBarMenuItem
的IsEnabled
屬性不會受到尊重。
只需包含使用Microsoft.Phone.Shell來獲取.cs文件中的命名空間,您就可以執行以下操作:
ApplicationBar.Enable();
和
ApplicationBar.Disable();
根據http://new.efficientcoder.net/2010/10/windows-phone-7-quick-tip-17.html
嘗試這個 :
XAML:
<shell:ApplicationBar IsVisible="False">
的.cs
Dispatcher.BeginInvoke(() =>
{
UIHelper.ToggleVisibility(Canvas_LocationAR_Trans);
UIHelper.ToggleVisibility(Grid_LocARLoadingGrid);
**ApplicationBar.IsVisible = true;**
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.