I have an WPF application. I have two datagrids, one contains a list of indicators and another datagrid that I want to show further details of the selected indicator of the top datagrid.
However my detail grid does not show any data and I can't work out why. I should point out that the master datagrid is populating fine. I have put a break in the setter of the property IndicatorSelected and can see it is being called when an item is selected & the see the data is correct but is just not being displayed in the detail datagrid.
XAML
<DataGrid x:Name="dgModels" Grid.Column="0"
ItemsSource="{Binding Path=IndicatorList}"
SelectedItem="{Binding Path=IndicatorSelected}"
AutoGenerateColumns="false">
<DataGrid.Columns>
<DataGridTextColumn Header="Model" Binding="{Binding Name}" IsReadOnly="True"/>
<DataGridCheckBoxColumn Header="Run" Binding="{Binding Run}" IsReadOnly="false"/>
</DataGrid.Columns>
</DataGrid>
<DataGrid x:Name="dgParameterInfo" Grid.Column="1"
ItemsSource="{Binding Path=IndicatorSelected}"
AutoGenerateColumns="false">
<DataGrid.Columns>
<DataGridTextColumn Header="Parameter Name" Binding="{Binding Path=Name}" IsReadOnly="True"/>
<DataGridTextColumn Header="Default Value" Binding="{Binding Path=DefaultValue}" IsReadOnly="True"/>
<DataGridTextColumn Header="Run Value" Binding="{Binding Path=RunValue}" IsReadOnly="True"/>
<DataGridTextColumn Header="Parameter Type" Binding="{Binding Path=ParaType}" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
C#
class ViewModel : INotifyPropertyChanged
{
List<IndicatorWrapper> _indicatorList;
IndicatorWrapper _indicatorWrapper;
public List<IndicatorWrapper> IndicatorList
{
get { return _indicatorList; }
set
{
_indicatorList = value;
OnPropertyChanged("IndicatorList");
}
}
public IndicatorWrapper IndicatorSelected
{
get { return _indicatorWrapper; }
set
{
_indicatorWrapper = value;
OnPropertyChanged("IndicatorWrapper");
}
}
public ViewModel()
{
DatabaseRetrieveSimulator db = new DatabaseRetrieveSimulator();
IndicatorList = db.GetIndicators();
}
}