2011-07-07 13 views
0

私はスタックパネルを持っていて、バインディングのカスタムオブジェクト "Questions"パスにdatacontextを設定しています。実行時にフレームワーク要素を追加して、textblockのプロパティをBinding()に設定すると、QuestionAnswerがオブジェクト。 QuestionTextを表示したい。クラスは抽象クラスなのでしょうか?何もSilverlightバインドの質問

public class Page 
{ 
     public int PageID { get; set; } 
     public ObservableCollection<QuestionAnswer> Questions { get; set; } 
} 

public abstract class QuestionAnswer 
    { 
     public int QuestionID { get; set; } 
     public string QuestionText { get; set; } 
     public QuestionType QuestionType { get; set; } 
     public Dictionary<string, string> AnswerOptions { get; set; } 
     public string AnswerText { get; set; } 
     public AnswerResponse AnswerResponse { get; set; } 
    } 
+1

あなたのコードバインディングを表示する – Mediator

答えて

1

バインディングはの名前にしている画面に表示されなかっI TextBoxQuestionAnswerようQuestionAnswerから継承するいくつかのクラスを持って、CheckboxQuestionAnswerなど

私はバインディング(「TextBoxQuestionAnswer.QuestionText」)を使用してみてください クラス名ではなく、Binding("TextBoxQuestionAnswer.QuestionText")が無効です。

スタックパネルは、コレクションへのバインディングにはあまり役に立ちません。アイテムテンプレートを持つコンテナが必要なので、アイテムごとにコレクション(リストボックス、グリッドなど)にバインドすることができます。

これを明確にするために、実際にXamlとバインディングコードを確認する必要があります。

関連する問題