I have a simmalar question to these to items here and here
Question now edited to include further info
I have a wpf c# (EDIT solution which has 3 projects in. The projects are a project call CH_CustomerOutlook and references the second project DAL project, the third is a CustomLibrary End Edit) The CH_CustomerOutlook project has the main window as normal on this is a DataGrid with a public observatable collection of my own type called named Outlooks
For the Class CustomerOutlook (Edit is in the DAL project and ) I have set up INotifyPropertyChanged and in the handle for the NotifyPropertyChanged method I want to access this Observable collection Outlooks in the main window and use it in a class method to update the totals on the DataGrid
Any help would be great thanks
The code is
public partial class MainWindow : Window
{
public static ProjectSettings Settings = new ProjectSettings();
// define new observable collection for data grid
public static ObservableCollection<SysproDAL.CustomerOutlook> OutlookCol = new ObservableCollection<SysproDAL.CustomerOutlook>();
public MainWindow()
{
InitializeComponent();
Settings.SetFromFile(Settings);
}
~The Customer outlook class code is
public class CustomerOutlook: INotifyPropertyChanged
{
//For CustomerOutlook static non changing propetties
public string Status { get; set; }
//For Return Merchandise changing propetties
private DateTime entrydate;
public DateTime EntryDate { get { return this.entrydate; }
set
{
if(this.entrydate != value)
{
this.entrydate = value;
this.NotifyPropertyChanged("EntryDate");
}
} }
//more properties defines etc
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propName));
this.Status = "u";
if (propName == "M1")
{
//Want to Access public observable collection "Outlooks" from main Window
//The call method UpdateTotals (Outlooks);
}
}
}
public static void UpdateTotals(ObservableCollection<CustomerOutlook> Col)
{
var item = Col.FirstOrDefault(i => i.Status == "T");
if (item != null)
{
item.M1 = Col.Sum(x => x.M1);
item.M2 = Col.Sum(x => x.M2);
item.M3 = Col.Sum(x => x.M3);
}
}