Hello,
I have a WPF application which incorporates the MVVM pattern. I have a viewmodel class which basically has two properties:
01.private SeriesMappingCollection _mapCollection; 02.private ArrayList _joints; 03.public SeriesMappingCollection MapCollection 04.{ 05. get { return _mapCollection; } 06. set 07. { 08. if (_mapCollection != value) 09. { 10. _mapCollection = value; 11. OnPropertyChanged("MapCollection"); 12. } 13. } 14.} 15. 16.public ArrayList Joints 17.{ 18. get { return _joints; } 19. set 20. { 21. if (_joints != value) 22. { 23. _joints = value; 24. OnPropertyChanged("Joints"); 25. } 26. } 27.}
The values of Mapcollection and Joints are set using a BackgroundWorker. When the data has been fetched, the GetAlertCompleted function is fired and the Mapcollection and Joints properties are set. This consequently fires the OnPropertyChanged() function of the view model
01.public ViewModel() 02.{ 03. workerAlerts = new BackgroundWorker(); 04. workerAlerts.DoWork += (o, args) => args.Result = 05. VizBackend.GetAlert.(_ipAdd,_selectedPeriod); 06. 07. workerAlerts.RunWorkerCompleted += GetAlertCompleted; 08.} 09. 10.private void GetAlertCompleted(object sender, RunWorkerCompletedEventArgs e) 11.{ 12. 13. var alertData = e.Result as AlertData; 14. Joints = alertData.Joints; 15. MapCollection = alertData.MapCollection; 16. }
And in the main window I have:
01.private readonly ViewModel vm; 02.vm = (ViewModel)DataContext; 03.vm.PropertyChanged += VmPropertyChanged; 04. 05.private void VmPropertyChanged(object sender, PropertyChangedEventArgs e) 06. { 07. switch (e.PropertyName) 08. { 09. case "MapCollection": 10. this.radChart.SeriesMappings = vm.MapCollection; 11. break; 12. 13. case "Joints": 14. this.radChart.ItemsSource = vm.Joints; 15. break; 16. } 17. }
I would appreciate if you could point out where the problem might be. Thanks.
<
telerik:RadGridView Name="UserListGrid" DockPanel.Dock="Top" Height="520"
ScrollMode="RealTime"
UseAlternateRowStyle="True"
AutoGenerateColumns="False"
ShowGroupPanel="False"
IsReadOnly="False"
RowIndicatorVisibility ="Visible"
CanUserFreezeColumns="False"
SelectionMode="Single"
ItemsSource="{Binding OperatorInfoItems, Mode=TwoWay}"
SelectedItem="{Binding SelectedRow, Mode=TwoWay}"
IsSynchronizedWithCurrentItem="True"
SelectionChanged="UserListGrid_SelectionChanged">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn UniqueName="Cars" DataType="{x:Null}" Header="Names" IsVisible="True" IsFilterable="False" IsGroupable="False" IsReadOnly="True" IsSortable="False" Width="150"/>
<telerik:GridViewComboBoxColumn ItemsSource="{Binding Parts}" Header="Parts"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
But after running the project i could only see names and a data binding error message instead of a populated combobox.
Pl tell me what to do.