c# - 如何在组合框中添加一些图像作为下拉菜单?
问题描述
我有一些快速图标,使我的软件易于使用。但现在根据我的客户要求,我需要将这些图标设置为下拉菜单。有谁知道如何做到这一点?
我已经尝试过正常的组合框代码 XAML。但无法添加图像。在代码隐藏或 DbModels 中有没有更好的方法?
<ComboBox HorizontalAlignment="Center" Grid.Row="2"
Grid.Column="5" x:Name="DropDownSearchMode" Style="{StaticResource
ComboBoxStyle}">
<ComboBoxItem Content="X"/>
<ComboBoxItem Content="Y"/>
<ComboBoxItem Content="Z"/>
</ComboBox>
我想要一些图标来显示下拉菜单,而不是 X、Y 和 Z。谁能帮我?
解决方案
像这样:
<StackPanel Margin="10">
<ComboBox>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="red.png" />
<TextBlock Foreground="Red">Red</TextBlock>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="green.png" />
<TextBlock Foreground="Green">Green</TextBlock>
</StackPanel>
</ComboBoxItem>
<ComboBoxItem>
<StackPanel Orientation="Horizontal">
<Image Source="blue.png" />
<TextBlock Foreground="Blue">Blue</TextBlock>
</StackPanel>
</ComboBoxItem>
</ComboBox>
</StackPanel>
推荐阅读
- reactjs - 如何使用 react-leaflet-pixi-overlay 创建自定义图标?
- amazon-web-services - 从 AWS 上的 Go EC2 环境流式传输标准输出日志
- javascript - 如何在反应中使用赋值或函数获取数据
- javascript - Symfony,谷歌分析:ga 未定义
- node.js - 注销后在登录时记录旧用户数据以使用 JWT 做出反应
- reactjs - 当我使用 window.innerWidth 在类名之间切换时,如何在调整大小时使反应应用程序响应?
- python - pandas read_csv 在 Mac OS 上通过 cron 运行时不起作用
- android - 在 Flutter 应用程序中使用 android.hardware.usb
- tensorflow - Tensor2tensor:我的自定义问题从未注册过注册表问题
- c# - 如何在单个应用程序中处理多个域?ASP.net core 3.0(剃须刀页面,天蓝色)