tags:

views:

5295

answers:

1

I am creating menus in WPF programatically using vb.net. Can someone show me how I can add separator bar to a menu in code? No xaml please.

+11  A: 

WPF has a Separator control for just that purpose and it also separates your menu items when the appear on a toolbar. From the MSDN docs:

A Separator control draws a line, horizontal or vertical, between items in controls, such as ListBox, Menu, and ToolBar. Separator controls do not react to any keyboard, mouse, mouse wheel, or tablet input and cannot be enabled or selected.

In code:

using System.Windows.Controls;

//

Menu myMenu = new Menu();
myMenu.Items.Add(new Separator());
Jeff Donnici