나는 바보 같은 짓을하고 있다고 확신하지만, 내 인생에서 나는 지금 당장 생각할 수 없습니다. ComboBox는 Layout 객체 목록에 데이터 바인딩됩니다. 목록은 처음에 비어 있지만 사물은 시간이 지남에 따라 추가됩니다.WPF 데이터 바인딩 된 ComboBox는 ItemsSource 목록의 첫 번째 항목 만 표시합니다.
목록에서 모델을 처음 업데이트하면이 업데이트는 ComboBox에 올바르게 반영됩니다. 그러나 목록 자체에 이러한 항목이 포함되어 있음을 알 수 있지만 이후의 업데이트는 ComboBox에 나타나지 않습니다. 첫 번째 업데이트가 작동 한 이후로 데이터 바인딩이 정상임을 알았습니다. 여기서 내가 뭘 잘못하고 있니?
은 여기 (요약 된)을 XAML :
<Grid HorizontalAlignment="Stretch">
<ComboBox ItemsSource="{Binding Path=SavedLayouts, diagnostics:PresentationTraceSources.TraceLevel=High}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedItem="{Binding LoadLayout}" Height="25" Grid.Row="1" Grid.Column="0"></ComboBox>
</Grid>
그리고 모델의 관련 부분 :
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)
하지만이 11 번째 항목은 ComboBox에 표시되지 않습니다.
아이디어가 있으십니까?