相关疑难解决方法(0)

覆盖本地资源字典中的系统颜色

我试图隐藏指示 WPF 中的选择的视觉提示ListBox这个答案表明这应该通过覆盖SystemColorsfor that来工作ListBox

我创建了一个新的 WPF 项目并进行了MainWindow.xaml如下编辑:

<Window x:Class="WpfListboxWithoutSelection.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:WpfListboxWithoutSelection"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        mc:Ignorable="d"
        Title="MainWindow" Height="150" Width="325">
  <Grid>
    <ListBox>
      <ListBox.Resources>
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent" />
        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />
        <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent" />
      </ListBox.Resources>
      <s:String>Item 1</s:String>
      <s:String>Item 2</s:String>
      <s:String>Item 3</s:String>
    </ListBox>
  </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用,窗口显示如下:

知道我做错了什么吗?如何删除所选项目和悬停项目上出现的蓝色?

wpf xaml listbox systemcolors visual-studio-2015

5
推荐指数
2
解决办法
3865
查看次数

禁用在 ListView 中选择项目

对于我正在开发的社交网络应用程序,我尝试使用 ListView 显示评论,但我不希望在单击时突出显示它。

我尝试使用

`((ListView)sender).SelectedItem = null;` in a selected event but that still shows it being selected for a second. I need it to never show.
Run Code Online (Sandbox Code Playgroud)

我还尝试将列表视图设置为

IsEnabled="False"

还尝试将它放在查看单元格中,但这会导致按钮和单击事件不起作用。

c# xaml xamarin xamarin.forms

1
推荐指数
1
解决办法
2434
查看次数