private void ButtonAddImage_Click(object sender, RoutedEventArgs e) { SelectButton button = new SelectButton() { MinWidth = 10, MinHeight = 10, DefaultBrush = new SolidColorBrush(Color.FromRgb(236, 240, 241)), Hover = new SolidColorBrush(Color.FromArgb(60, 233, 30, 99)), OnChecked = new SolidColorBrush(Color.FromRgb(240, 98, 146)) }; button.Content = new Image() { Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/Controls/image.png")), }; ContentPanel.Children.Add(button); if (lastChecked != null) { lastChecked.SetCheckedNoCall(false); } Content_Image content_Image = new Content_Image(); content.contents.Add(content_Image); button.Tag = content_Image; button.OnCheckChanged += Button_OnCheckChanged; button.SetChecked(true); lastChecked = button; }
private void Button_OnCheckChanged(object sender, bool IsChecked) { if (lastChecked != null && lastChecked != sender) { lastChecked.SetCheckedNoCall(false); } SelectButton ths = (SelectButton)sender; ths.SetCheckedNoCall(true); lastChecked = ths; if (ths != null) { if (((Content_Default)ths.Tag).ContentType() == 0) { editor.Content = new ContentEditor_Image(data, ths); } else if (((Content_Default)ths.Tag).ContentType() == 1) { editor.Content = new ContentEditor_Text(data, ths); } else if (((Content_Default)ths.Tag).ContentType() == 2) { editor.Content = new ContentEditor_Splitter(data, ths); } else if (((Content_Default)ths.Tag).ContentType() == 3) { editor.Content = new ContentEditor_PageNumber(data, ths); } else if (((Content_Default)ths.Tag).ContentType() == 4) { editor.Content = new ContentEditor_Answers(data, ths); } else if (((Content_Default)ths.Tag).ContentType() == 5) { editor.Content = new ContentEditor_Date(data, ths); } } }