Runi Chatterjee
Runi Chatterjee

Reputation: 85

Horizontal MenuItem in wpf

How to create a horizontal menu item in wpf with MenuItem containing some images.What I need is a main menu and there will be sub menu and those sub menu s will not be in a vertical way as they are usually by default. rather they should be in a horizontal way. Moreover each and every MenuItem should also contain some images.Can anyone help .

Upvotes: 1

Views: 593

Answers (1)

Anindya
Anindya

Reputation: 2686

I also done a similar kind of thing in my project . I am giving my code here.

<MenuItem Style="{StaticResource HepsiSubMenuStyle}" HorizontalAlignment="Left" Width="80" Height="20" Background="Red"  BorderThickness="0" Cursor="Hand" Grid.Column="1" Margin="20,0,0,0" >

                        <MenuItem.Icon>
                            <Image Source="Resource/MenuHepsi.jpg" Height="20" Width="80" VerticalAlignment="Center"/>
                        </MenuItem.Icon>

                        <MenuItem.ItemsPanel >
                            <ItemsPanelTemplate>

                                <VirtualizingStackPanel Orientation="Horizontal" Background="Red"  />


                            </ItemsPanelTemplate>
                        </MenuItem.ItemsPanel>

                        <MenuItem  Style="{StaticResource HepsiSubMenuStyle}" Cursor="Hand" Width="80" Height="90" Padding="0" BorderThickness="0" >
                            <MenuItem.Icon>
                                <Image Source="/EfesBetGUI;component/Resource/Images/Footbal.png" Height="26" Width="26" HorizontalAlignment="Center" Margin="0,20,0,0" />
                            </MenuItem.Icon>
                            <MenuItem.Header>
                                <TextBlock Text="Futbol" Foreground="White" FontSize="14" Padding="0,0,0,15">
                                </TextBlock>
                            </MenuItem.Header>
                        </MenuItem>
                        <MenuItem  Style="{StaticResource HepsiSubMenuStyle}" Cursor="Hand" Width="80" Height="90" Padding="0" BorderThickness="0" >
                            <MenuItem.Icon>
                                <Image Source="/EfesBetGUI;component/Resource/Images/BasketBall.png" Height="26" Width="26" HorizontalAlignment="Center" Margin="0,20,0,0" />
                            </MenuItem.Icon>
                            <MenuItem.Header>
                                <TextBlock Text="Basketbol" Foreground="White" FontSize="14" Padding="0,0,0,15">
                                </TextBlock>
                            </MenuItem.Header>

                        </MenuItem
>
                        <MenuItem  Style="{StaticResource HepsiSubMenuStyle}" Cursor="Hand" Width="80" Height="90" Padding="0" BorderThickness="0" >
                            <MenuItem.Icon>
                                <Image Source="/EfesBetGUI;component/Resource/Images/Duello.png" Height="26" Width="49" HorizontalAlignment="Center" Margin="0,20,0,0" />
                            </MenuItem.Icon>
                            <MenuItem.Header>
                                <TextBlock Text="Duello" Foreground="White" FontSize="14" Padding="0,0,0,15">
                                </TextBlock>
                            </MenuItem.Header>

                        </MenuItem>
                    </MenuItem>

Upvotes: 1

Related Questions