title: WPF MeasureOverride called multiple times after multiple PropertyChanged notifications
body: <p>In my application, I have a graph (Custom Wpf Panel) with Wpf controls as elements. The elements are custom controls derived from Wpf Control. DataTemplates associate the controls to their view models.
  The view models collection, "GraphElements" is binded to the itemsControl as shown below.</p>
  
  <pre><code>&lt;ItemsControl x:Name="PART_GraphItemsControl" Grid.Column="1"
                VerticalAlignment="Stretch" 
                HorizontalAlignment="Left"
                ItemsSource="{Binding Path=GraphElements}"
                VirtualizingStackPanel.IsVirtualizing="True"
                VirtualizingStackPanel.VirtualizationMode="Recycling"&gt;
      &lt;ItemsControl.ItemsPanel&gt;
          &lt;ItemsPanelTemplate&gt;
              &lt;local:GraphDesignerPanel HorizontalAlignment="Stretch"
                                        VerticalAlignment="Top" /&gt;
          &lt;/ItemsPanelTemplate&gt;
      &lt;/ItemsControl.ItemsPanel&gt;
  &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>The elements in the graph can vary from 2 to 500. Under certain mode of the application, the elements display their value. To display the value, the ViewModel for the element fires the <code>INotifyPropertyChanged.PropertyChanged("VariableValue")</code></p>
  
  <p><strong>Issue:</strong>
  When i have 100+ elements in the graph, each elements view model fires INotifyPropertyChanged.PropertyChanged to have the elements value displayed. This calls MeasureOverride 100+ times leading to memory and peformance issues.</p>
  
  <p>How can I reduce the number of MeasureOverride calls?</p>
  
  <h2>XAML for Value display for the graph element:</h2>
  
  <pre><code> &lt;TextBlock  
      Text="{Binding Path=VariableValue, StringFormat={}({0})}" Width="60"
      FontSize="11" Name="txtBlk"&gt;
  &lt;/TextBlock&gt;
  </code></pre>
  
  <p>The TextBlock above is collapsed if VariableValue is null</p>
  
  <pre><code>&lt;DataTrigger Binding="{Binding Path=VariableValue}" Value="{x:Null}"&gt;
      &lt;Setter TargetName="txtBlk"  Property="Visibility" Value="Collapsed"/&gt;
  &lt;/DataTrigger&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong> The issue is reproducible in the sample at the link given below. Download, build, debug. Once App is opened, set a breakpoint in Window.xaml.cs MeasureOverride. Come back to the App and hit the "Click Me" button. The breakpoint is hit 11 times !.</p>
  
  <p><a href="http://sivainfotech.co.uk/measureoverrideissue.zip" rel="nofollow">http://sivainfotech.co.uk/measureoverrideissue.zip</a></p>
  
  <p>Any ideas greatly appreciated.</p>