title: Check if a ToggleSwitch is on
body: <p>I know it must be a silly thing, but I can't find how to check if a ToggleSwitch is on.
  This is my code: </p>
  
  <pre><code>    private void ToggleNamePrivacy_Toggled(object sender, RoutedEventArgs e)
      {
          if (ToggleNamePrivacy.IsOn == true)
          {
              PrivacyImage.Source = new BitmapImage(new Uri("Assets/public.png", UriKind.Relative));
          }
          else
          {
              PrivacyImage.Source = new BitmapImage(new Uri("Assets/private.png", UriKind.Relative));
          }
      }
  </code></pre>
  
  <p>The if clause is causing a </p>
  
  <blockquote>
    <p>NullReferenceException: Object reference not set to an instance of an
    object.</p>
  </blockquote>
  
  <p>Neither is working if I write:</p>
  
  <pre><code>if(ToggleNamePrivacy.IsOn)
  </code></pre>
  
  <p>Why?</p>