void AddChannelToUI(RSSChannel channel) { var uiChannel = new ChannelListItem { DataContext = channel }; uiChannel.ContextMenu = new ContextMenu(); MenuItem deleteButton = new MenuItem { Header = "Delete" }; deleteButton.Click += delegate { StackChannels.Children.Remove(uiChannel); SaveChanges(); }; uiChannel.ContextMenu.Items.Add(deleteButton); uiChannel.MouseDoubleClick += delegate { LoadRSSItems(channel.Link); }; StackChannels.Children.Add(uiChannel); }
void btnAdd_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtLink.Text) && !string.IsNullOrEmpty(txtTitle.Text)) { if(RSSDataManeger.IsValidChannel(txtLink.Text)) { channel = new RSSChannel() { Link = txtLink.Text, Title = txtTitle.Text }; DialogResult = true; } else { MessageBox.Show("Channel is invalid and cannot be used!","RSSReader"); txtLink.Text = ""; } } else { MessageBox.Show("Empty fields are not allowed!","RSSReader"); } }