private void DetailButton_Click(object sender, RoutedEventArgs e) { SeletedButton = ((sender as Button).Parent as Grid).Children[0] as Button; DetailWindow window = new DetailWindow(); window.DataContext = (((((sender as Button).Parent as Grid).Parent as Grid).Parent as StackPanel).Parent as Grid).DataContext; window.SetColorFavoriteButton += Window_SetColorFavoriteButton; window.Show(); }
private void SearchResult_Selected(object sender, RoutedEventArgs e) { DetailWindow window = new DetailWindow(); window.DataContext = (sender as StackPanel).DataContext; window.Closing += new CancelEventHandler((s, o) => { this.SearchText.Text = ""; CheckAddIntoFavoriteList(window.DataContext as Recipe); LoadElementsWithPageNumber(); }); window.Show(); }