Hi,
i have a problem with the databinding of a datagrid in WPF.
my model:
public class CheckLogModel : ObservableObject
{
public int Id { get; set; }
public DateTime TimeStamp { get; set; }
public decimal MandantNr { get; set; }
public decimal PrintJobNr { get; set; }
public decimal HgoNr { get; set; }
public decimal GoNr { get; set; }
}
MainviewModel:
private ObservableCollection<CheckLogModel> _checkLogEntries = new ObservableCollection<CheckLogModel>();
public ObservableCollection<CheckLogModel> CheckLogEntries {
get {
return _checkLogEntries;
}
set {
if (value == _checkLogEntries) return;
_checkLogEntries = value;
RaisePropertyChangedEvent("CheckLogEntriesChanged");
}
}
private void SearchWqButtonClick(object sender) {
var searchModel = new SearchCheckLogModel {
MandantNr = _selectedMandant.Nummer,
GoNr = Converter.ConvertToDecimal(_goNr),
HgoNr = Converter.ConvertToDecimal(_hgoNr),
PrintJobNr = Converter.ConvertToDecimal(_printjobNr),
Id = Converter.ConvertToInt(_id)
};
if (searchModel.IsAllCriteriasEmpty()) {
return;
}
CheckLogEntries = CheckLogRepository.GetCheckLogEntities(searchModel);
}
}
Main Window XAML:
DataContext="{Binding Main, Source={StaticResource Locator}}"
<DataGrid ItemsSource="{Binding CheckLogEntries}"
Grid.Column="1"
Grid.Row="0"
AutoGenerateColumns="true"
>
</DataGrid>
App.xaml:
<application.resources>
<resourcedictionary>
<vm:viewmodellocator x:key="Locator"
="" d:isdatasource="True" xmlns:vm="clr-namespace:NetigateLogViewer.ViewModel">
What I have tried:
When executing the programm I get a correct resultset of "CheckLogEntries" from the static method "CheckLogRepository.GetCheckLogEntities" when i execute the method "SearchWqButtonClick" plus a correct execution of the property setter so that the property should be set.
But the rows are not displayed in the datagrid of the main window.
I guess there is sth wrong with the binding, but have no idea what it is...
Any help is appreciated?