Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

how can i handle CommandPreExecute and Excuted Event in WPF

$
0
0

Modalview

namespace WpfApplication10
{
    public class ViewModel
    {
        private SaveCommand _SaveCommand = new SaveCommand();

        public SaveCommand SaveCommand
        {
            get { return _SaveCommand; }
            set { _SaveCommand = value; }
        }


    }

    public class SaveCommand : ICommand
    {
        public bool CanExecute(object parameter)
        {
            return true;
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            MessageBox.Show("Save Command Execute handle...");
        }
    }

}

CS Code

namespace WpfApplication10
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.DataContext = new ViewModel();
            InitializeComponent();
        }

        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}

Xaml Code

<Grid><Button Name="BtnSave" Width="100" Height="23" Content="Save" Click="BtnSave_Click" 
                Command="{Binding  SaveCommand}"></Button></Grid>

how can i handle PreExecute and Executed Event ?




Prem Shah


Viewing all articles
Browse latest Browse all 18858

Trending Articles