gpt4 book ai didi

.net - WPF中的水平MenuItem

转载 作者:行者123 更新时间:2023-12-03 10:37:39 26 4
gpt4 key购买 nike

如何在wpf中使用包含一些图像的MenuItem创建一个水平菜单项。我需要的是一个主菜单,并且将有子菜单,而那些子菜单将不是垂直方式,因为它们通常是默认设置。相反,它们应该处于水平状态。而且每个MenuItem还应该包含一些图片。任何人都可以帮助。

最佳答案

我在项目中也做了类似的事情。我在这里给出我的代码。

<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>

关于.net - WPF中的水平MenuItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19335790/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com