title: Silverlight: binding object collection to datatemplate in itemscontrols binds empty objects to property
body: <p>Let me explain my situation. I have made a user control that contains an ItemsControl</p>
  
  <pre><code>&lt;ItemsControl Name="itemControlReviewTags"&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackPanel&gt;
                      &lt;my:ReviewControl ReviewEvent="{Binding}" /&gt;
                          &lt;TextBlock Text="{Binding Text}" /&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>This ItemsControl is bound to an observablecollection in the code behind</p>
  
  <pre><code>public ObservableCollection&lt;TagEvent&gt; tagItems = new ObservableCollection&lt;TagEvent&gt;();
  </code></pre>
  
  <p>The collection is set on the ItemsControl like so</p>
  
  <pre><code>itemControlReviewTags.ItemsSource = tagItems;
  </code></pre>
  
  <p>The TagEvent class is defined like below. The class is added to the collection at certain events.</p>
  
  <pre><code>public class TagEvent : EventArgs
  {
      public string Text { get; set; }
      public string Comment { get; set; }
      public string Value { get; set; }
      public DateTime Time { get; set; }
      public string Type { get; set; }
  }
  </code></pre>
  
  <p>The ReviewControl in the datatemplate had a DependencyProperty like so </p>
  
  <pre><code>public TagEvent ReviewEvent
      {
          get 
          {
              return (TagEvent)GetValue(ReviewEventProperty); 
          }
          set 
          {
              SetValue(ReviewEventProperty, value); 
          }
      }
  
      public static readonly DependencyProperty ReviewEventProperty = DependencyProperty.Register("ReviewEvent", typeof(TagEvent), typeof(ReviewControl), new PropertyMetadata(new TagEvent() { Comment = "hallo", Text = "De tag", Time = DateTime.Now, Type = "Mark", Value = "Mark" }, ReviewEvent_PropertyChangedCallback));
  
      private static void ReviewEvent_PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)  
      {
          ReviewControl reviewControl = (ReviewControl)d;
          reviewControl.LoadReviewEvent();
      }
  </code></pre>
  
  <p>The strange thing is that when I run my progran the TagEvents get added to the collection and the ItemsControl shows the datatemplate for every item. The testblock I used to verify the value of the properties on the TagEvents shows the proper value of the text property. But in the ReviewEvent Dependency property I get only "empty" objects (all values empty string or default date). Those objects replace the default value as i can see that as the oldvalue in the DP callback.</p>
  
  <p>I could understand the ItemsControl not showing the items, but why it is showing item that look like it's doing "new TagEvent" for every item in the collection is beyond me. Hope someone here has a suggestion for me. I tried implementing INotifyPropertyChanged on the TagEvent, but that did not seem to change anything. I could split out the properties of the TagEvent class but I don't see why I would have to do that, when I could pass the object. </p>
  
  <p>Help?</p>