Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 列表视图和触发器;项目不';使用鼠标单击时无法选中_Wpf_Xaml - Fatal编程技术网

Wpf 列表视图和触发器;项目不';使用鼠标单击时无法选中

Wpf 列表视图和触发器;项目不';使用鼠标单击时无法选中,wpf,xaml,Wpf,Xaml,问题可通过以下代码重现: <ListView> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="Horizonta

问题可通过以下代码重现:

<ListView>

    <ListView.ItemContainerStyle>
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="{x:Null}" />
                    <Setter Property="BorderBrush" Value="{x:Null}" />
                </Trigger>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#FFEDC4" />
                    <Setter Property="BorderBrush" Value="{x:Null}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </ListView.ItemContainerStyle>

    <ListView.Items>
        <ListViewItem Height="70">Some item</ListViewItem>
        <ListViewItem Height="70">Some item</ListViewItem>
        <ListViewItem Height="70">Some item</ListViewItem>
        <ListViewItem Height="70">Some item</ListViewItem>
    </ListView.Items>

</ListView>

某项
某项
某项
某项
控件在正确单击鼠标时出现问题。单击项目文本可以很好地工作并选择项目。单击文本之外的任何位置(因此在
TextBox
之外,但在
ListViewItem
之内)在80%的时间内有效,但每5次无效。未选中该项目。这不仅是视觉样式错误,而且项目确实没有被选中,可以用键盘箭头键进行检查

在添加触发器之后,一切都开始了。删除
IsMouseOver
触发器帮助

这里可能有什么问题?

使用

<Setter Property="Background" Value="Transparent" />

而不是
{x:Null}
。否则将无法捕获鼠标事件。

使用

<Setter Property="Background" Value="Transparent" />


而不是
{x:Null}
。否则,将无法捕获鼠标事件。

难以置信,它可以工作。谢谢。我真的很惊讶
{x:null}
做出了如此奇怪的行为,而不是让它完全不起作用。难以置信,它起作用了。谢谢。我真的很惊讶
{x:null}
做出了如此奇怪的行为,而不是让它完全不起作用。