I have a WPF application with Caliburn.Micro. I am trying to populate a new combobox I just added, but it stays empty, though the other comboboxes on the same view are populated. I debuged, so I know that the GeorgaphyNames source collection in the ViewModel is populated correctly. Could you please help?
Here is my code:
Model:
public class GeographyName : PropertyChangedBase
{
private string _name;
public string Name
{
get { return _name; }
set
{
if (_name == value) return;
_name = value;
NotifyOfPropertyChange(() => Name);
}
}
...
}
View:
<ComboBox Grid.Row="6" Grid.Column="1" Name="GeographyNames" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedItem="SelectedGeographyName" Style="{StaticResource DetailCombo}" />
ビューモデル:
private BindableCollection<GeographyName> _geographyNames;
public BindableCollection<GeographyName> GeorgaphyNames
{
get { return _geographyNames; }
private set
{
if (_geographyNames == value)
return;
_geographyNames = value;
NotifyOfPropertyChange(() => GeorgaphyNames);
}
}
private GeographyName _selectedGeographyName;
public GeographyName SelectedGeographyName
{
get { return _selectedGeographyName; }
set
{
if (_selectedGeographyName == value)
return;
_selectedGeographyName = value;
NotifyOfPropertyChange(() => SelectedGeographyName);
IsModified = true;
}
}
コンボボックスは、別のコンボボックスで選択を変更すると取り込まれます:
private Ldc _selectedLdc;
public Ldc SelectedLdc
{
get { return _selectedLdc; }
set
{
if (_selectedLdc == value)
return;
_selectedLdc = value;
NotifyOfPropertyChange(() => SelectedLdc);
if (SelectedLdc != null)
{
GeorgaphyNames = GeographyName.GetData(SelectedLdc.LdcId);
}
IsModified = true;
}
}