/// <summary> /// /// </summary> /// <param name="contactservice"></param> public mainviewmodel(icontactservice contactservice, defaultviewmodel defaultviewmodel, contactviewmodel contactviewmodel, contactscollectionviewmodel contactcollectionviewmodel) { icon = "/artifacts/images/logo.jpg"; iconheight = 100; iconwidth = 100; _contactservice = contactservice; // a bit ugly way of hooking event handlers contactviewmodel.saved += (s, e) => { content = pages.Where(x => x.displayname.Equals("allcontacts")).First().refresh(); }; contactcollectionviewmodel.editting += (s, e) => { var contacollection = s as contactscollectionviewmodel; var contact = pages.Single(x => x.displayname.Equals("new contact")) as contactviewmodel; if (contact != null && contacollection != null) { contact.model = contacollection.current.model; content = contact; } }; contactviewmodel.close += close; contactcollectionviewmodel.close += close; content = defaultviewmodel; pages = new List <pageviewmodel> { defaultviewmodel, contactviewmodel, contactcollectionviewmodel }; }
/// <summary> /// /// </summary> /// <param name="contactservice"></param> public mainviewmodel(icontactservice contactservice, defaultviewmodel defaultviewmodel, contactviewmodel contactviewmodel, contactscollectionviewmodel contactcollectionviewmodel) { icon = "/artifacts/images/logo.jpg"; iconheight = 100; iconwidth = 100; _contactservice = contactservice; // a bit ugly way of hooking event handlers contactviewmodel.saved += (s, e) => { content = pages.Where(x => x.displayname.Equals("allcontacts")).First().refresh(); }; contactcollectionviewmodel.editting += (s, e) => { var contacollection = s as contactscollectionviewmodel; var contact = pages.Single(x => x.displayname.Equals("new contact")) as contactviewmodel; if(contact != null && contacollection != null) { contact.model = contacollection.current.model; content = contact; } }; contactviewmodel.close +=close; contactcollectionviewmodel.close += close; content = defaultviewmodel; pages = new List<pageviewmodel> { defaultviewmodel, contactviewmodel, contactcollectionviewmodel }; }