Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make s WPF menu look like a Windows Forms ToolStripMenu?

I am new to WPF. And by new I mean I just started it today after getting .net 3.5. I usually do GUI Development in Windows Forms and like the awesome ToolStripMenu. But when I saw the WPF Menu, it was so ugly that it reminded me of my Win32 Api days. Is there any way to change the style of a WPF menu to make it look like a Windows Forms menu?

like image 439
ApprenticeHacker Avatar asked Jun 30 '11 07:06

ApprenticeHacker


People also ask

Can we use WinForms in WPF?

That is, you can build WinForms user controls and embed them in WinForms applications, and likewise build WPF user controls and embed them in WPF applications.

How do I add a system window form in WPF?

Say, you want to use Windows Forms' ListBox control in your WPF application, you simply have to add the below code inside your Grid tag in XAML. The WindowsFormsHost tag is used to host Windows Forms control and wf:ListBox tag represents the Windows Forms ListBox.


2 Answers

try this:

An introduction to styling and templating: http://msdn.microsoft.com/en-us/library/ms745683.aspx

A new styling for toolbar http://msdn.microsoft.com/en-us/library/aa970772.aspx

Alternatively search for wpf ToolBar style

Edit: Yes - but add a menu like this and the toolbar alters the menu style (paste in new project):

<Grid>
<Grid.RowDefinitions>
  <RowDefinition Height="Auto"></RowDefinition>
  <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ToolBarTray >
  <ToolBar >
  <Menu>
    <MenuItem Header="Hey">
      <MenuItem Header="lo"></MenuItem>
    </MenuItem>
    <MenuItem Header="Ho">
      <MenuItem Header="la"></MenuItem>
    </MenuItem>
  </Menu>
</ToolBar>
</ToolBarTray>

like image 120
Rune Andersen Avatar answered Oct 05 '22 22:10

Rune Andersen


The Menu, like most WPF controls has very little styling by default.

But that's just by default, you can add your own styles and outshine WinForms very easily .

Just a little starter:

    <Menu DockPanel.Dock="Top" >
        <Menu.Background>
            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="White" Offset="0" />
                <GradientStop Color="Blue" Offset="1" />
            </LinearGradientBrush>
        </Menu.Background>
        <MenuItem Header="_File" >
like image 24
Henk Holterman Avatar answered Oct 05 '22 22:10

Henk Holterman