WPF数据绑定组合框仅显示ItemsSource列表的第一项
我肯定我在做一些愚蠢的事情,但我现在想不起来了。我有一个组合框,它是绑定到布局对象列表的数据。列表最初是空的,但随着时间的推移会添加内容 当模型第一次更新列表时,此更新将正确反映在组合框中。但是,即使我可以看到列表本身包含这些项目,组合框中也不会显示后续更新。由于第一次更新有效,我知道数据绑定是正常的-那么我在这里做错了什么 以下是XAML(节略): 在输出窗口中,我可以看到正在进行的更新:WPF数据绑定组合框仅显示ItemsSource列表的第一项,wpf,data-binding,combobox,Wpf,Data Binding,Combobox,我肯定我在做一些愚蠢的事情,但我现在想不起来了。我有一个组合框,它是绑定到布局对象列表的数据。列表最初是空的,但随着时间的推移会添加内容 当模型第一次更新列表时,此更新将正确反映在组合框中。但是,即使我可以看到列表本身包含这些项目,组合框中也不会显示后续更新。由于第一次更新有效,我知道数据绑定是正常的-那么我在这里做错了什么 以下是XAML(节略): 在输出窗口中,我可以看到正在进行的更新: System.Windows.Data Warning: 91 : BindingExpression
System.Windows.Data Warning: 91 : BindingExpression (hash=64564967): Got PropertyChanged event from TickerzModel (hash=43624632)
System.Windows.Data Warning: 97 : BindingExpression (hash=64564967): GetValue at level 0 from TickerzModel (hash=43624632) using RuntimePropertyInfo(SavedLayouts): List`1 (hash=16951421 Count=11)
System.Windows.Data Warning: 76 : BindingExpression (hash=64564967): TransferValue - got raw value List`1 (hash=16951421 Count=11)
System.Windows.Data Warning: 85 : BindingExpression (hash=64564967): TransferValue - using final value List`1 (hash=16951421 Count=11)
但是我没有得到组合框中的第11项
有什么想法吗?令人尴尬-需要使用一个可观察的集合-我已经很久没有与WPF合作了
public IList<Layout> SavedLayouts { get { return _layouts; } }
public Layout SaveLayout( String data_ )
{
Layout theLayout = new Layout( SaveLayoutName );
_layouts.Add( theLayout );
try
{
return theLayout;
}
finally
{
PropertyChangedEventHandler handler = PropertyChanged;
if( handler != null )
{
handler( this, new PropertyChangedEventArgs( "SavedLayouts" ) );
}
}
}
public class Layout
{
public String Name
{
get;
private set;
}
}
System.Windows.Data Warning: 91 : BindingExpression (hash=64564967): Got PropertyChanged event from TickerzModel (hash=43624632)
System.Windows.Data Warning: 97 : BindingExpression (hash=64564967): GetValue at level 0 from TickerzModel (hash=43624632) using RuntimePropertyInfo(SavedLayouts): List`1 (hash=16951421 Count=11)
System.Windows.Data Warning: 76 : BindingExpression (hash=64564967): TransferValue - got raw value List`1 (hash=16951421 Count=11)
System.Windows.Data Warning: 85 : BindingExpression (hash=64564967): TransferValue - using final value List`1 (hash=16951421 Count=11)