void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.Change = ((WeatherAgent_Demo.ValueChange)(target)); return; case 2: this.Morning = ((System.Windows.Controls.TextBox)(target)); return; case 3: this.Day = ((System.Windows.Controls.TextBox)(target)); return; case 4: this.Evening = ((System.Windows.Controls.TextBox)(target)); return; case 5: this.Night = ((System.Windows.Controls.TextBox)(target)); return; case 6: this.Changed = ((System.Windows.Controls.Button)(target)); return; case 7: this.Close = ((System.Windows.Controls.Button)(target)); return; case 8: this.Date = ((System.Windows.Controls.TextBlock)(target)); return; } this._contentLoaded = true; }
private void Button_Click(object sender, RoutedEventArgs e) { var TextBlocks = TreeVisualHelp.FindVisualChildren <TextBlock>(sender as Button).ToList(); List <string> DateList = new List <string>(); var AllTextBlocks = TreeVisualHelp.FindVisualChildren <TextBlock>(InfoList).ToList(); foreach (TextBlock txt in AllTextBlocks) { if (txt.Name == "Date") { DateList.Add(txt.Text); } } string Date = TextBlocks[0].Text.ToString(); string Morning = TextBlocks[5].Text.ToString(); string Day = TextBlocks[6].Text.ToString(); string Evening = TextBlocks[7].Text.ToString(); string Night = TextBlocks[8].Text.ToString(); //индекс визуального элемента, на котором произошел клик Int32 NumberOfChild = 0; foreach (string date in DateList) { NumberOfChild++; if (date == Date) { break; } } ValueChange newWindow = new ValueChange(NumberOfChild, Date, Morning, Day, Evening, Night); newWindow.Owner = this; newWindow.ShowDialog(); }