private void AddFilter_OnClick(object sender, RoutedEventArgs e) { EditFilterDialog dlg = new EditFilterDialog(this); dlg.ShowModal(); /*string xaml_item = XamlWriter.Save(FilterTemplateItem); * StringReader stringReader = new StringReader(xaml_item); * XmlReader xmlReader = XmlReader.Create(stringReader); * CheckBox newItem = (CheckBox)XamlReader.Load(xmlReader); * newItem.Name = "FilterClone1"; * newItem.Content = "FilterClone1"; * newItem.Visibility = Visibility.Visible; * MenuItem it = newItem.ContextMenu.Items[0] as MenuItem; * it.Command = DeleteFilter; * it = newItem.ContextMenu.Items[1] as MenuItem; * it.Command = EditFilter; * FilterListBox.Items.Add(newItem);*/ }
void ExecuteEditFilterCommand(object sender, ExecutedRoutedEventArgs ev) { ListBoxItem it = ev.OriginalSource as ListBoxItem; CheckBox chk_box = it.Content as CheckBox; if (chk_box == null) { return; } LogFilterData filter_data = chk_box.DataContext as LogFilterData; if (filter_data == null) { return; } EditFilterDialog dlg = new EditFilterDialog(this); dlg.InitData(chk_box); dlg.ShowModal(); }