コード例 #1
0
        private void BtnAddFolder_Click(object sender, RoutedEventArgs e)
        {
            var newControl = new User_Controls.EncapsulationControl();

            newControl.BtnEncapsulationControlExit.Click += RemoveControl_Click;
            FolderEntries.Add(newControl);
        }
コード例 #2
0
        private void RemoveControl_Click(object sender, RoutedEventArgs e)
        {
            User_Controls.EncapsulationControl rmEntry = null;

            foreach (var entry in FolderEntries)
            {
                if (entry.BtnEncapsulationControlExit == ((Button)sender))
                {
                    rmEntry = entry;
                    break;
                }
            }

            if (rmEntry != null)
            {
                FolderEntries.Remove(rmEntry);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }