Exemplo n.º 1
0
        /*   private void IncExpCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
         * {
         *     if (IncExpCB.SelectedIndex == 0)
         *     {
         *         //SplitTSW.IsEnabled = true;
         *       //  DrawersCB.Visibility = Visibility.Collapsed;
         *     }
         *     else
         *     {
         *       //  SplitTSW.IsEnabled = false;
         *      //   DrawersCB.Visibility = Visibility.Visible;
         *     }
         * } */

        private void IncDeleteBt_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement fe = sender as FrameworkElement;

            if (fe != null)
            {
                //So since the data context is the specific item in the list, the listbox item and the button's data
                // context are the same, so you can set that item as the selected item!!
                IncLB.SelectedItem = fe.DataContext;
            }

            int index = IncLB.SelectedIndex;

            if (budget.transactions[index].Value > 0m)
            {
                budget.DeleteIncome(budget.transactions[index].Value, budget.transactions[index].Description,
                                    budget.transactions[index].Date, budget.transactions[index].Bin);
            }
            else
            {
                budget.DeleteExpense(budget.transactions[index].Value, budget.transactions[index].Description,
                                     budget.transactions[index].Date, budget.transactions[index].Bin);
            }
        }