title: Change the background color of XAML Map pushpins using triggers
body: <p>I'm trying to change the background color of the XAML map pushpins using a DataTemplate trigger, but maybe there is something wrong in my code. The idea is that the ItemSource of the map is binded to an ObservableCollection of PushpinModel and when the value of the property IsOnline is true, then the pushpin should became green.</p>
  
  <p>Here is my <code>Geolocation.xaml</code>:</p>
  
  <pre><code>&lt;m:Map CredentialsProvider="XXX" Mode="Road"&gt;
      &lt;m:MapItemsControl Name="Pushpins" ItemsSource="{Binding PushpinCollection}" &gt;
          &lt;m:MapItemsControl.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;m:Pushpin Location="{Binding Path=Location}" /&gt;
                  &lt;DataTemplate.Triggers&gt;
                      &lt;DataTrigger Binding="{Binding Path=IsOnline}" Value="True"&gt;
                          &lt;Setter Property="m:Pushpin.Background" Value="Green"&gt;&lt;/Setter&gt;
                      &lt;/DataTrigger&gt;
                  &lt;/DataTemplate.Triggers&gt;
              &lt;/DataTemplate&gt;
          &lt;/m:MapItemsControl.ItemTemplate&gt;
      &lt;/m:MapItemsControl&gt;
  &lt;/m:Map&gt;
  </code></pre>
  
  <p>and here is the View Model <code>GeolocationViewModel.cs</code>:</p>
  
  <pre><code>namespace MyNamespace
  {
      internal class Pushpins : ObservableCollection&lt;PushpinModel&gt; { }
  
      internal class PushpinModel
      {
          public PushpinModel(double latitude, double longitude)
          {
              Location = new Location(latitude, longitude);
          }
          public Location Location { get; set; }
          public bool IsOnline { get; set; } = false;
      }
  
      internal class GeolocationViewModel : INotifyPropertyChanged
      {
          public GeolocationViewModel()
          {
              pushpinCollection = new Pushpins();
               CreatePushpins();
          }
  
          private Pushpins pushpinCollection;
          public Pushpins PushpinCollection
          {
              get { return pushpinCollection;  }
          }
  
          private void CreatePushpins()
          {
              Random rnd = new Random();
  
              for (int i = 1; i &lt;= 100; i++)
              {
                  PushpinModel pin = new PushpinModel(rnd.NextDouble() * 180 - 90, rnd.NextDouble() * 360 - 180);
  
                  if (rnd.NextDouble() &gt;= 0.5)
                      pin.IsOnline = true;
  
                  pushpinCollection.Add(pin);
              }
              OnPropertyChanged("PushpinCollection");
          }
  
          #region IPropertyChange
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected void OnPropertyChanged(string propertyName)
          {
              PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
          }
          #endregion
      }
  }
  </code></pre>
  
  <p>I have some doubts about the <code>Property</code> of <code>Setter</code>, cause I think I'm not changing the right item.</p>
  
  <p>Any suggestions? Thank you guys!</p>