Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a View with a button as follows:

XAML
<Button  Content="Upload File" Margin="692,8,9,5" Grid.Row="2" Width="109" Background="Olive" Command="{Binding UploadBtnClick}"/>


XAML.cs
public ICommand UploadBtnClick { get; set; }
      public SourceFolder(List<string> selectedFiles)
      {
          InitializeComponent();
          UploadBtnClick = new RelayCommand(UploadBtnExecute, UploadBtnCanExecute);

      }


public bool UploadBtnCanExecute(object param)
      {
          return true;
      }
      public void UploadBtnExecute(object param)
      {
          MessageBox.Show("hello");
      }


not firing on button click

What I have tried:

not firing on button click
Posted
Updated 8-Jan-21 4:37am
Comments
Richard Deeming 8-Jan-21 9:53am    
Check the Visual Studio output window for binding errors.

1 solution

Check the DataContext.

public SourceFolder(List<string> selectedFiles) {
   InitializeComponent();
   UploadBtnClick = new RelayCommand(UploadBtnExecute, UploadBtnCanExecute);

   this.DataContext = this;
}


Any time the DataContext is set / reset, bindings will "bind / rebind".
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900