【问题标题】:Disable the blue selection item from the list view从列表视图中禁用蓝色选择项
【发布时间】:2014-02-04 10:59:41
【问题描述】:

我正在使用以下代码,我希望在以下情况下禁用蓝色标记 用户用光标悬停列表,我该怎么做?
我尝试了资源 代码没有成功。

我无法将其更改为列表框...(因为我有我猜的列)

        <ListView x:Name="listView" ItemsSource="{Binding Dispaly}" Height="250" 
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"  FontFamily="Calibri">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Key}" Header="{x:Static res:Resources.AB}"   Width="150" />
                    <GridViewColumn DisplayMemberBinding="{Binding Value}" Header="{x:Static res:Resources.CC}" Width="150"/>
                </GridView>
            </ListView.View>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="BorderThickness" Value="0 0 0 1"/>
                    <Setter Property="BorderBrush" Value="AntiqueWhite"/>

                </Style>
            </ListView.ItemContainerStyle>

            <ListView.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" />
            </ListView.Resources>

        </ListView>

【问题讨论】:

标签: wpf xaml


【解决方案1】:

您可以编辑 ListView 控件模板并从控件模板中删除 IsSelected 触发器。

http://msdn.microsoft.com/en-us/library/ms788717.aspx

【讨论】:

  • 它有什么帮助,我试过没有成功,你能提供例子吗?
【解决方案2】:

这是如何编辑 ListViewItem 控件模板的示例。在按钮中插入你想要的任何东西

        <ListView.Resources>
            <Style TargetType="{x:Type ListViewItem}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                            <Button Background="Transparent" Foreground="White"  FontSize="16" FontWeight="Light">
                                <Button.Content>
                                    <GridViewRowPresenter Content="{TemplateBinding Content}" />
                                </Button.Content>
                            </Button>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ListView.Resources>

你也可以试试listView的编辑风格。为属性 IsSelected 添加一个 Trigger 并在 Trigger 的 Setter 中设置 listviewitem 的 Background

【讨论】:

    【解决方案3】:

    您只需要为listviewitem的样式添加不带setter的触发器IsMouseOver。

      <ListView>
        <ListView.ItemContainerStyle>
                <Style>
                   <Style.Triggers>
                      <Trigger Property="IsMouseOver" Value="True">
                      </Trigger>
                   </Style.Triggers>
                </Style>
             </ListView.ItemContainerStyle>
        </ListView>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-04
      • 1970-01-01
      • 2010-10-28
      • 2012-04-03
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      相关资源
      最近更新 更多