我想從一個列表框,看起來像這樣我的Windows 8 Store應用內獲得的SelectedItem:獲取的SelectedItem從Control
<ListBox x:Name="listBox" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Foreground="Black" BorderThickness="0" Background="#FFD8D8D8" />
的問題是,列表框不火的SelectedItem propertie。我必須使用IsSynchronizedWithCurrentItem =「True」但出現一個錯誤,表示true不支持此屬性。我需要做什麼或者是否有其他方法來獲得SelectedItem特性?
我有這樣的代碼背後:
namespace ExampleApp
{
public sealed partial class MainPage : Page, INotifyPropertyChanged
{
private object currentItem;
//Constructor and so on
public object SelectedItem
{
get { Debug.WriteLine("get"); return currentItem; }
set { Debug.WriteLine("set"); currentItem = value; NotifyPropertyChanged(); }
}
}
}
【如何通過列表框將selectedItem作爲一個按鈕命令參數?(HTTP的可能重複://計算器.com/questions/18257516/how-to-pass-listbox-selecteditem-as-command-in-a-button) – RubberDuck 2016-06-10 19:14:45