public void OpenPopupExecute() { Menus = new ObservableCollection <object>(); Menus.Add(new MenuItem { Header = "默认列表", Command = new DelegateCommand(new Action(AddToDefaultList)) }); Menus.Add(new Separator()); var titles = new CustomTitleManager().GetList(); titles.ForEach(item => { Menus.Add(new MenuItem { Header = item.Title, Command = new DelegateCommand <object>(new Action <object>(AddToCustomList)), CommandParameter = item.Title }); }); }
public void RefreshCustomList() { CustomList = new StackPanel(); var titles = new CustomTitleManager().GetList(); titles.ForEach(item => { ImageRadioButton btn = new ImageRadioButton(); btn.SetValue(ImageRadioButton.StyleProperty, Application.Current.Resources["MenuRadioButtom"]); btn.GroupName = "MenuItem"; btn.Content = item.Title; var menu = new ContextMenu(); var title = new TextBlock { Text = "删除歌单" }; title.MouseLeftButtonUp += ClickDeleteList; title.Tag = new TagInfo(0, item.Title); menu.Items.Add(title); btn.ContextMenu = menu; btn.Command = new DelegateCommand <object>(new Action <object>(ClickCustomList)); btn.CommandParameter = item.Title; CustomList.Children.Add(btn); }); }