public ModalWindow(ModalWindowsDataContext modalWindowsDataContext) { InitializeComponent(); DataContext = modalWindowsDataContext; base.DataContext = DataContext; }
public MainWindowDataContext() { _tags = new Resources.Tags(); var modalWidowDataContext = new ModalWindowsDataContext(); ModalWindow = new ModalWindow(modalWidowDataContext); smartThoughts = new ObservableCollection <SmartThought>(SmartThoughts.GetAll()); usedTags = new List <string>(); var tagsControlDataContext = new TagsControlDataContext(_tags); TagsControl = new TagsControl(tagsControlDataContext); var smartThoughtsEditorControlDataContext = new SmartThoughtsEditorControlDataContext(st => { SmartThoughts.Upsert(st); }, _tags); smartThoughtsEditorControl = new SmartThoughtsEditorControl(smartThoughtsEditorControlDataContext); var smartThoughtsPreviewControlDataContext = new SmartThoughtsPreviewControlDataContext(smartThoughts); smartThoughtsPreviewControl = new SmartThoughtsPreviewControl(smartThoughtsPreviewControlDataContext); MainContent = smartThoughtsPreviewControl; smartThoughtsPreviewControlDataContext.SmartThoughtSelected += (s, a) => { smartThoughtsEditorControlDataContext.Load(a); MainContent = smartThoughtsEditorControl; ShouldTagsBeShown = false; }; smartThoughtsEditorControlDataContext.CloseRequired += (s, a) => { MainContent = smartThoughtsPreviewControl; ShouldTagsBeShown = true; tagsControlDataContext.RefreshTags(); }; smartThoughtsEditorControlDataContext.SmartThoughtTagEditRequired += (s, a) => { modalWidowDataContext.ShowModalContent(a); }; smartThoughtsEditorControlDataContext.SmartThoughtTagCloseRequired += (s, a) => { modalWidowDataContext.HideModal(); }; tagsControlDataContext.TagSelected += (s, a) => { usedTags.Add(a); var st = SmartThoughts.GetByTags(usedTags); smartThoughts.Clear(); foreach (var smartThought in st) { smartThoughts.Add(smartThought); } }; tagsControlDataContext.TagRemoved += (s, a) => { usedTags.Remove(a); smartThoughts.Clear(); IList <SmartThought> st = new List <SmartThought>(); if (usedTags.Any()) { st = SmartThoughts.GetByTags(usedTags); } else { st = SmartThoughts.GetAll(); } foreach (var smartThought in st) { smartThoughts.Add(smartThought); } }; }