0

ComboBoxVB.Net WPF アプリケーションを使用しています。

<ComboBox HorizontalAlignment="Left" Margin="77,49,0,0" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Path=Server.RecipeList()}" DisplayMemberPath="RecipeID" SelectedValuePath="RecipeID"/>

コード ビハインドには、Server というクラス変数があります。

Public Server As BatchServer = New BatchServer

私の Server オブジェクトには、次のものがありますList

Private mRecipeList As New List(Of Recipe)

そして、サーバーのデフォルトのコンストラクターは

Public Sub New()
    Server = New BatchRemote.RemoteSupport
    PopulateRecipeList()
End Sub

ListこれをにバインドしたいComboBoxので、リスト内の各レシピの RecipeID を表示する必要があります。私のデータ バインディングは最初のコード ブロックと同じように見えますが、アプリケーションを実行するとComboBoxは常に空になります。

ここで何が間違っていますか?

4

2 に答える 2

0

まず、 interfaceを正しく実装Serverするとして宣言する必要があります。次に、 についても同じことを行う必要があります。次に、これを好きになることができるはずです:public Property INotifyPropertyChangedRecipeListBind

<ComboBox HorizontalAlignment="Left" Margin="77,49,0,0" VerticalAlignment="Top" 
Width="120" ItemsSource="{Binding Path=Server.RecipeList}" DisplayMemberPath="RecipeID"
SelectedValuePath="RecipeID" />
于 2013-10-31T17:23:50.003 に答える