title: Add Custom Cursor to a Canvas
body: <p>I have a resource code block with several cursors to later be used at runtime in the functionality of a WPF canvas. When I try to load it in the loaded event of Window, it will generate a <code>NullReferenceException</code>:</p>
  <blockquote>
  <p>Object Reference not set to an Instance of an object</p>
  </blockquote>
  <pre class="lang-xml prettyprint-override"><code>&lt;Window.Resources&gt;
      &lt;ResourceDictionary&gt;
          &lt;Image x:Key=&quot;CursCruz&quot; Cursor=&quot;C:/Users/Marin/source/repos/AnalisisMamposteriaWPF/Imagenes 24/CIRCURX.cur&quot; /&gt;
          &lt;Image x:Key=&quot;CurUno&quot; Cursor=&quot;C:/Users/Marin/source/repos/AnalisisMamposteriaWPF/Imagenes 24/Cursor_Uno.cur&quot; /&gt;
          &lt;Image x:Key=&quot;CurDos&quot; Cursor=&quot;C:/Users/Marin/source/repos/AnalisisMamposteriaWPF/Imagenes 24/Cursor_Dos.cur&quot; /&gt;
      &lt;/ResourceDictionary&gt;
  &lt;/Window.Resources&gt;
  
  </code></pre>
  <p>Code behind</p>
  <pre class="lang-cs prettyprint-override"><code>private void Window_Loaded(object sender, RoutedEventArgs e)
  {
      picCanva.Background = Brushes.Black; // Para futuro cambio de background
      zoom = 1.0;
      Cursor AgregarCursor = ((Image)this.Resources[&quot;cursCruz&quot;]).Cursor;
      Cursor ACursorCirculoCruz = ((Image)this.Resources[&quot;curUno&quot;]).Cursor;
      Cursor ACursorCirculoEqui = ((Image)this.Resources[&quot;curDos&quot;]).Cursor;
      MouseMove += picCanva_MouseMove_NotDown;
  }
  </code></pre>