私は c# で開発する初心者です。この例 を勉強していますhttp://msdn.microsoft.com/en-us/library/hh286405%28v=vs.92%29.aspx このリンクでは、私のコードをどこで見ることができますか?問題があると思います: http://pastebin.com/LYqzuqYb アプリを実行して button1 をクリックすると、無効なキャスト エラーが発生しました。
Category = (DB.Elements)listPicker.SelectedItem
しかし、どこに問題があるのか わかりません。アントニオに敬意を表します
詳細情報 listPicker の挿入要素にこれを使用します
public Inserimento()
{
InitializeComponent();
List<Elenco> source = new List<Elenco>();
source.Add(new Elenco() { Elemento = "Value1"});
source.Add(new Elenco() { Elemento = "Value2" });
source.Add(new Elenco() { Elemento = "Value3" });
source.Add(new Elenco() { Elemento = "Value4" });
this.listPicker.ItemsSource = source;
}
Elemento はこのクラスです。listPicker に要素を挿入して保存するためにこのクラスを使用します
namespace Example.ViewModel{
public class Elenco
{ public string Elemento
{
get;
set;
}
}}