ウォッチリストを次のように定義しました。
// a named list of VariableWatchers
public class WatchList : List<VariableWatcher>
{
private string _name;
public WatchList(string name) : base()
{
_name = name;
}
public override string ToString()
{
return _name;
}
}
次のように、WatchList のリストを ComboBox の ItemsSource プロパティにバインドしました。
<ComboBox x:Name="WatchListDropdown"
ItemsSource="{Binding Path=WatchLists}"
VerticalAlignment="Center"
Margin="5"/>
「WatchLists」は、私の DataContext の次のプロパティを指します。
public IList<WatchList> WatchLists
{
get { return _watchLists; }
}
リスト内のすべてのエントリが _name 変数ではなく「(コレクション)」として表示されることを除いて、すべてがうまく機能します。ToString にブレークポイントを設定し、ある時点で呼び出され、正しい値を返していることを確認しましたが、どういうわけか ComboBox に "(Collection)" と表示されたままです。