title: MVVM Pattern tutorial for UWP but it wont bind Commands why?
body: <p>Ok. I'm following a tutorial to master MVVM Pattern to my app.</p>
  
  <p>I've followed the tutorial quite well, I got to the part of commandings and when I try to apply command to a button it doesnt seem to work at all, my button never disables.
  I've seen other MVVM sources and my code seems to be fine besides I found this tutorial on internet it was meant for WPF, but it also apply for UWP Windows 10 Apps.</p>
  
  <p>So I'll paste my classes and Xaml views.</p>
  
  <p>this is my Model:</p>
  
  <pre><code>using System.ComponentModel;
  
  namespace MVVMDemo.Model
  {
  public class Student : INotifyPropertyChanged
  {
      private string firstName;
      private string lastName;
  
      public string FirstName
      {
          get
          {
              return firstName;
          }
  
          set
          {
              if (firstName != value)
              {
                  firstName = value;
                  RaisePropertyChanged("FirstName");
                  RaisePropertyChanged("FullName");
              }
          }
      }
  
      public string LastName
      {
          get { return lastName; }
  
          set
          {
              if (lastName != value)
              {
                  lastName = value;
                  RaisePropertyChanged("LastName");
                  RaisePropertyChanged("FullName");
              }
          }
      }
  
      public string FullName
      {
          get
          {
              return firstName + " " + lastName;
          }
      }
  
      public event PropertyChangedEventHandler PropertyChanged = delegate { };
  
      private void RaisePropertyChanged(string property)
      {
          PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
      }
  }
  }
  </code></pre>
  
  <p>The model code I believe has no errors on it.
  this is my ViewModel:</p>
  
  <pre><code>using MVVMDemo.Model;
  using System.Collections.ObjectModel;
  
  namespace MVVMDemo.ViewModel
  {
  public class StudentViewModel
  {
      /*Let’s add a property of MyICommand type in StudentView Model class. 
       * Now we need to construct an instance in the StudentViewModel. We will
       * use the overloaded constructor of MyICommand that takes two parameters.*/
      public MyICommand DeleteCommand { get; set; }
  
      /*Now add the implementation of OnDelete and CanDelete methods.*/
      public StudentViewModel()
      {
          LoadStudents();
          DeleteCommand = new MyICommand(OnDelete, CanDelete);
      }
  
      private bool CanDelete()
      {
          //if (SelectedStudent != null)
          //    return true;
          //return false;
          return SelectedStudent != null;
      }
  
      private void OnDelete()
      {
          Students.Remove(SelectedStudent);
      }
  
      /*We also need to add a new SelectedStudent so that the user 
       * can delete the Selected Item from ListBox.*/
      private Student _selectedStudent;
  
      public Student SelectedStudent
      {
          get
          {
              return _selectedStudent;
          }
          set
          {
              _selectedStudent = value;
              DeleteCommand.RaiseCanExecuteChanged();
          }
      }
      public ObservableCollection&lt;Student&gt; Students
      {
          get;
          set;
      }
  
  
      public void LoadStudents()
      {
          ObservableCollection&lt;Student&gt; students = new ObservableCollection&lt;Student&gt;();
  
          students.Add(new Student { FirstName = "Mark", LastName = "Allain" });
          students.Add(new Student { FirstName = "Allen", LastName = "Brown" });
          students.Add(new Student { FirstName = "Linda", LastName = "Hamerski" });
  
          Students = students;
      }
  }
  }
  </code></pre>
  
  <p>This is my ViewModelLocator:</p>
  
  <pre><code>using MVVMDemo.ViewModel;
  
  namespace MVVMDemo.VML
  {
  public class ViewModelLocator
  {
  private static StudentViewModel studentViewModel = new StudentViewModel();
  
      public static StudentViewModel StudentViewModel
      {
          get { return studentViewModel; }
      }
  }
  }
  </code></pre>
  
  <p>and at Last this is my View my UserControl StudentView</p>
  
  <pre><code>&lt;UserControl
      x:Class="MVVMDemo.Views.StudentView"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:MVVMDemo.Views"
      xmlns:vml="using:MVVMDemo.VML"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"
      DataContext="{Binding Source={StaticResource mainViewModelLocator}, Path=StudentViewModel}"
      d:DesignHeight="300"
      d:DesignWidth="400"&gt;  
  
  &lt;!--We will apply MVVM Using ItemTemplates--&gt;
  &lt;UserControl.Resources&gt;
      &lt;DataTemplate x:Key = "studentsTemplate"&gt;
  
          &lt;StackPanel Orientation = "Horizontal"&gt;
              &lt;TextBox Text = "{Binding Path = FirstName, Mode = TwoWay}" 
          Width = "100" Margin = "3 5 3 5"/&gt;
  
              &lt;TextBox Text = "{Binding Path = LastName, Mode = TwoWay}" 
          Width = "100" Margin = "0 5 3 5"/&gt;
  
              &lt;TextBlock Text = "{Binding Path = FullName, Mode = OneWay}" 
          Margin = "0 5 3 5"/&gt;
          &lt;/StackPanel&gt;
  
      &lt;/DataTemplate&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;Grid&gt;
      &lt;StackPanel Orientation="Horizontal"&gt;
          &lt;!--In StudentView.xaml, we need to add SelectedItem property in a ListBox
          which will bind to the SelectStudent property.--&gt;
          &lt;ListView ItemsSource="{Binding Students}" 
                    ItemTemplate="{StaticResource studentsTemplate}"
                    SelectedItem="{Binding SelectedStudent}"/&gt;
  
          &lt;Button Content = "Delete"  
                  Command="{Binding DeleteCommand}"
                  HorizontalAlignment = "Left" 
                  VerticalAlignment = "Top" 
                  Width = "75"/&gt;
      &lt;/StackPanel&gt;        
  &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>I'm applying the viewmodellocator on the app.xaml file at application level:</p>
  
  <pre><code>&lt;Application.Resources&gt;
      &lt;vml:ViewModelLocator x:Key="mainViewModelLocator"/&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <p>and I call my view on the main page like this:</p>
  
  <p></p>
  
  <p>can somebody help me, I've run this code on VS2015 and VS2017 and the Delete button never gets enabled and it also doesnt delete the rows from the listview or listbox i've tried changing them and nothing seems to be different.</p>
  
  <p>I've even had a commanding implemetation without using the relaycommand pattern as it is used here.
  I would appreciate your help.</p>
  
  <p>Thanks!!!</p>