欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 国际 > 基于ListBox制作一个好看的侧边菜单导航栏

基于ListBox制作一个好看的侧边菜单导航栏

2025/5/23 8:19:59 来源:https://blog.csdn.net/qq_21419015/article/details/140590372  浏览:    关键词:基于ListBox制作一个好看的侧边菜单导航栏

1.代码实现

MainWindow.xaml 代码如下:

<Window x:Class="UIDamo_WPF.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:UIDamo_WPF"mc:Ignorable="d"Title="MainWindow" Height="450" Width="800" Background="#2b2b2b"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="130"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><Rectangle Fill="#111111"/><ListBox Margin="0 5 0 0" Background="Transparent" Foreground="White" BorderThickness="0" FontSize="16" Name="listMenu"><ListBox.ItemContainerStyle><Style TargetType="ListBoxItem"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ListBoxItem"><StackPanel Height="35" Orientation="Horizontal" Background="Transparent" Name="container" Cursor="Hand"><Rectangle Fill="Green" VerticalAlignment="Stretch" Width="5" Visibility="Hidden" Name="leftSlideRectangle"/><ContentPresenter  VerticalAlignment="Center" Margin="15 0 0 0"/></StackPanel><ControlTemplate.Triggers><Trigger Property="IsSelected" Value="True"><Setter Property="Visibility" Value="Visible" TargetName="leftSlideRectangle"/><Setter Property="Background" Value="#3a3a3a" TargetName="container"/></Trigger><Trigger Property="IsMouseOver" Value="True"><Setter Property="Visibility" Value="Visible" TargetName="leftSlideRectangle"/><Setter Property="Opacity" Value="0.5" TargetName="leftSlideRectangle"/><Setter Property="Background" Value="#1a1a1a" TargetName="container"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></ListBox.ItemContainerStyle><ListBoxItem  Content="首页"/><ListBoxItem  Content="用户管理"/><ListBoxItem  Content="权限设置"/><ListBoxItem  Content="菜单管理"/><ListBoxItem  Content="配置管理"/><ListBoxItem  Content="设备管理"/><ListBoxItem  Content="数据管理"/><ListBoxItem  Content="系统配置"/><ListBoxItem  Content="基础配置"/><ListBoxItem  Content="退出系统"/></ListBox></Grid>
</Window>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词