title: Fill a WPF Context Menu Dynamically
body: <p>I have a WPF context menu on a tray icon. What I need is to dynamically add Menu Items according to a collection binded in ViewModel.</p>
  
  <p>What is the best approach?
  I tried this</p>
  
  <pre><code>&lt;ContextMenu&gt;
      &lt;ContextMenu.ItemsSource&gt;
          &lt;CompositeCollection&gt;
              &lt;MenuItem ItemsSource="{Binding Path=RegisteredWindows}"&gt;
                  &lt;MenuItem.ItemContainerStyle&gt;
                      &lt;Style TargetType="{x:Type MenuItem}"&gt;
                          &lt;Setter Property="Header" Value="{Binding Path=Name}" /&gt;
                      &lt;/Style&gt;
                  &lt;/MenuItem.ItemContainerStyle&gt;
              &lt;/MenuItem&gt;
              &lt;MenuItem Header="Show/Hide All" Command="{Binding Path=HideShow}" /&gt;
              &lt;Separator /&gt;
              &lt;MenuItem Header="Exit" Command="{Binding Path=Quit}" /&gt;
          &lt;/CompositeCollection&gt;
      &lt;/ContextMenu.ItemsSource&gt;
  &lt;/ContextMenu&gt;
  </code></pre>
  
  <p>but I can't see text, only blank rows...</p>
  
  <p><em>*</em>*Solved. See my answer below.</p>