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

Disable a button in ViewModel

$
0
0

Original I have code event in code behind.

private async void Start_Click(object sender, RoutedEventArgs e)
{
     try
     {
         Start.IsEnabled = false;
         Start.IsHitTestVisible = false;
         Start.Background = Brushes.Red;

Now I want to move code to ViewModel as MVVW pattern.

<Button Grid.Column="1" Grid.Row="3" Command="{Binding StartProcess}" Width="200">Start</Button>

using GalaSoft.MvvmLight.Command; public RelayCommand StartProcess { get; set; } public MainWindowViewModel() { StopProcess = new RelayCommand(StopProcessExecute); // etc. } private void StartProcessExecute() { // how to disable the button. // blah blah }




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>