簡體   English   中英

Windows Phone 7中的應用程序欄項目

[英]Application Bar items in windows phone 7

在我的Windows Phone應用程序中,我有一個名為item_1的應用程序欄菜單項和radiobutton button_1,我已將item_1的IsEnabled屬性設置為false; 因此,當我檢查button_1時,應該將item_1的IsEnabled屬性設為true; 為此,我在C#中編寫了以下代碼

 public void button_1_checked(object sender,RoutedEventArgs e)
 {
    this.item_1.IsEnabled=true;
    -----rest of the code----
 }

但這給出了NullReferenceException,我應該怎么做才能啟用item_1?

這是因為ApplicationBar無法通過Name屬性正確綁定。 您需要通過代碼訪問它:

var button1 = (ApplicationBarIconButton) ApplicationBar.Buttons[0];
button1.IsEnabled = true;

此鏈接可能對您有所幫助: 如何:在代碼中創建應用程序欄

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM