Wednesday, April 15, 2009

Separator for Menu Item in XAML (WPF, Silverlight)

Trivial task and yet worth mentioning: You want a separator in your XAML based application (WPF or Silverlight)? Use System.Windows.Controls.Separator. In XAML write as follows:
<Menu ...
  <MenuItem ...
     <MenuItem ...
     <Separator />
     <MenuItem>
  </MenuItem>
</Menu>
In C# use:
using System.Windows.Controls;

Menu menu = new Menu();
...
menu.Items.Add(new Separator());

2 comments:

  1. Anonymous5:08 PM

    Thanks--this is exactly what I was looking for!

    ReplyDelete
  2. I don't believe this is supported in Silverlight. WPF only.

    ReplyDelete

All comments, questions and other feedback is much appreciated. Thank you!