Tuesday, July 26, 2011

WPF-Customized Menu

The coolest thing which I like about WPF is that we can cutomize its controls as per our needs.

Following XAML is generating a Menu with an Image

<MenuItem Name="mnuItemAlert" HorizontalAlignment="Left" FontFamily="Courier" FontSize="14" Header="Alerts" FlowDirection="LeftToRight">

<MenuItem.Icon>

<Image HorizontalAlignment="Left" Width="20" Height="25" Visibility="Visible" Source="Images/alert.gif" />

</MenuItem.Icon>

</MenuItem>

Now we can modify this XAML as per our need(by adding stack panel image and text appears much closer...)

<MenuItem Name="mnuItemAlert" HorizontalAlignment="Left" MouseEnter="mnuItemAlert_MouseEnter" FontFamily="Courier" FontSize="14" FlowDirection="LeftToRight">

<MenuItem.Header>

<StackPanel Orientation="Horizontal">



<TextBlock Margin="3" >Alerts</TextBlock>

<Image HorizontalAlignment="Left" Width="20" Height="25" Visibility="Visible" Source="Images/alert.gif" />



</StackPanel>

</MenuItem.Header>

</MenuItem>

No comments:

Post a Comment

If you’re using Visual Studio to build your .NET MAUI app on a Mac, locating the IPA (iOS App Package) file can be a bit tricky

  If you’re using   Visual Studio   to build your   .NET MAUI   app on a   Mac , locating the   IPA (iOS App Package)   file can be a bit tr...