Alessandro Del Sole's Blog

{ A programming space about Microsoft® .NET® }
posts - 1909, comments - 2047, trackbacks - 352

My Links

News

Your host

This is me! Questo spazio è dedicato a Microsoft® .NET®, di cui sono molto appassionato :-)

Cookie e Privacy

Microsoft MVP

My MVP Profile

Microsoft Certified Professional

Microsoft Specialist

Xamarin Certified Mobile Developer

Il mio libro su VB 2015!

Pre-ordina il mio libro su VB 2015 Pre-ordina il mio libro "Visual Basic 2015 Unleashed". Clicca sulla copertina per informazioni!

Il mio libro su WPF 4.5.1!

Clicca sulla copertina per informazioni! E' uscito il mio libro "Programmare con WPF 4.5.1". Clicca sulla copertina per informazioni!

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.
If you're not an Italian user, please visit my English blog

Le vostre visite

I'm a VB!

Guarda la mia intervista a Seattle

Follow me on Twitter!

Altri spazi

GitHub
I miei progetti open-source su GitHub

Article Categories

Archives

Post Categories

Image Galleries

Privacy Policy

WPF: Menus with different fonts

When implementing menus in WPF applications, you can assign different fonts (each with different properties) to each single header or command.

Consider the following XAML:

  <DockPanel LastChildFill="True">
    <Menu DockPanel.Dock="Top" VerticalAlignment="Top">
      <MenuItem Name="FileMenu" Header="File" FontFamily="Script MT Bold" FontSize="14" FontStyle="Italic" FontWeight="Medium">

        <MenuItem Name="FileVivaldiCommand" Header="Command with Vivaldi Font" FontFamily="Vivaldi" FontSize="16" FontWeight="Heavy">
          <MenuItem.Background>
            <LinearGradientBrush>
              <GradientStop Color="Red" Offset="0" />
              <GradientStop Color="Orange" Offset="0.5" />
              <GradientStop Color="Yellow" Offset="1" />
            </LinearGradientBrush>
          </MenuItem.Background>
        </MenuItem>
      </MenuItem>
    </Menu>
  </DockPanel>

We have drawn a File menu whose layout is set using the Script TM Bold font, with size of 14, italic, medium intensity. The Name has been assigned if you would interact with the graphical object via managed code.

The first command of the File menu is even identified with a Name attribute and is shown according to the Vivaldi font with size of 16, heavy intensity. We've also added a particular feature, a gradient background for this menu command. If you are a fan of this blog, you know very well this programming technique.

This is the result we obtain running the application:

Alessandro

Print | posted on lunedì 8 ottobre 2007 23:46 |

Powered by:
Powered By Subtext Powered By ASP.NET