2012-11-08 26 views
0

假的我在我的Windows Phone應用程序的應用程序欄集可視性,在WP7

<phone:PhoneApplicationPage.ApplicationBar> 
    <shell:ApplicationBar> 
     <shell:ApplicationBarIconButton x:Name="Refresh" IconUri="Images/appbar.sync.rest.png" Text="Actualiser" Click="ApplicationBarIconButton_Click" /> 
     <shell:ApplicationBarIconButton x:Name="Favorite" IconUri="Images/appbar.favs.addto.rest.png" Text="Favorite" Click="ApplicationBarIconButton_Click_1" /> 
    </shell:ApplicationBar> 
</phone:PhoneApplicationPage.ApplicationBar> 

我NEDD設置的<shell:ApplicationBarIconButton x:Name="Favorite" IconUri="Images/appbar.favs.addto.rest.png" Text="Favorite" Click="ApplicationBarIconButton_Click_1" /> 假能見度當我點擊

如何才能做到這一點? ?

問候

回答

3

您不能設置在應用欄各個按鈕的能見度倒塌。但是您可以使用IsEnabled屬性enable/disable或將其從ApplicationBar.Buttons.Remove(object)後面的代碼中動態移除,並傳遞您在click事件中收到的按鈕對象。我想它應該工作。

+0

是它.... –

0

你需要做的是在你的應用程序中有兩個不同的AppBars - 第一個是2 ApplicationBarIconButtons(刷新和收藏),第二個只有刷新ApplicationBarIconButton

在您的EventHandlerApplicationBarIconButton_Click_1中,您可以更改當前顯示給用戶的AppBar

像這樣的作品...

ApplicationBar appBar1 = new ApplicationBar(); 
ApplicationBarIconButton refreshIcon = new ApplicationBarIconButton(); 
refreshIcon.text = "Refresh"; 
refreshIcon.Click += new EventHandler(Refresh_Click); 
appBar1.add(refreshIcon); 

ApplicationBarIconButton favIcon = new ApplicationBarIconButton(); 
favIcon.text = "Refresh"; 
favIcon.Click += new EventHandler(Fav_Click); 
appBar1.add(favIcon); 

ApplicationBar appBar2 = new ApplicationBar(); 
ApplicationBarIconButton refreshIcon2 = new ApplicationBarIconButton(); 
refreshIcon2.text = "Refresh"; 
refreshIcon2.Click += new EventHandler(Refresh_Click); 
appBar2.add(refreshIcon2); 

ApplicationBar = appBar1; // Assign the AppBar with both buttons as the default. 

然後在EventHandlerFav_Click,寫

ApplicationBar = appBar2; // This will make the AppBar with only "Refresh" button visible giving the impression that the Favorite button has been made invisible.