2016-01-23 51 views
2

我作爲在ListView的項目模板用戶控件,當我鼠標懸停在一個特定的項目不突出它可是我有其他的列表視圖在我的項目中,該特定項目被突出顯示。Listiview項目上空盤旋時並不突出 - UWP(視窗10)

我已經刪除了代碼從我的用戶和複製/直接在我的DataTemplate粘貼它來檢查它是否是有關的事實,我使用的是用戶控件,但沒有什麼區別。

這ListView控件包含在SemanticZoom,所以我再次取出SemanticZoom檢查的行爲會發生變化,但都無濟於事!仍然不會突出顯示。

我所有的列表視圖有自己的SelectionMode設置爲單,我已經得到了在應用程序級別定義的風格,適用於所有我的列表視圖

這是我的用戶代碼:

<UserControl 
    x:Class="MyApp.UserControls.ZoomedIn" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="using:MyApp.UserControls" 
    xmlns:converters="using:MyApp.Converters" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" 
    d:DesignHeight="300" 
    d:DesignWidth="470"> 

    <UserControl.Resources> 
     <converters:WrapOnConverter x:Key="WrapOnConverter"/> 
    </UserControl.Resources> 

    <Grid x:Name="Details" 
      Background="White" 
      Grid.Column="0" 
      Grid.Row="0" 
      Margin="12,5,12,5"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="Auto"/> 
      <ColumnDefinition Width="*"/> 
     </Grid.ColumnDefinitions> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*" /> 
     </Grid.RowDefinitions> 
     <Image x:Name="Image" 
       Source="{Binding Image}" 
       Width="100" 
       Height="100" 
       Stretch="UniformToFill" 
       Grid.Row="0" 
       Grid.Column="0" 
       Grid.RowSpan="2" 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" /> 
     <Image x:Name="Image2" 
       Source="{Binding Image2}" 
       Width="30" 
       Height="30" 
       Margin="67,67,0,0" 
       Stretch="UniformToFill" 
       Grid.Row="0" 
       Grid.Column="0" 
       Grid.RowSpan="2" 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" /> 
     <Image x:Name="Image3" 
       Source="{Binding Image3}" 
       Width="30" 
       Height="30" 
       Margin="32,67,0,0" 
       Stretch="UniformToFill" 
       Grid.Row="0" 
       Grid.Column="0" 
       Grid.RowSpan="2" 
       HorizontalAlignment="Left" 
       VerticalAlignment="Top" />   
     <StackPanel Margin="5,0,5,0" 
        Grid.Row="0" 
        Grid.Column="1" 
        VerticalAlignment="Top"> 
      <TextBlock x:Name="Title" 
         Text="{Binding Title}" 
         Foreground="{ThemeResource 
         SystemControlForegroundAccentBrush}" 
         FontWeight="SemiBold" 
         VerticalAlignment="Top" 
         TextWrapping="{Binding 
         Converter={StaticResource WrapOnConverter}}" /> 
      <TextBlock x:Name="Time" 
         Text="{Binding Time}" 
         Foreground="DarkCyan" 
         VerticalAlignment="Top" 
         HorizontalAlignment="Left" 
         Margin="0,5,0,5" /> 
      <TextBlock x:Name="Description" 
         Text="{Binding Description}" 
         Foreground="Black" 
         TextWrapping="Wrap" 
         VerticalAlignment="Top" 
         HorizontalAlignment="Left" 
         MaxLines="2"/> 
     </StackPanel> 
    </Grid> 
</UserControl> 

而我的ListView的定義如下:

<ListView ItemsSource="{Binding Source={StaticResource cvsDetails}}" 
      SelectionMode="Single" 
      SelectedIndex="{Binding SelectedDetailIndex}" 
      SelectedItem="{Binding SelectedDetail, Mode=TwoWay}" 
      ItemContainerStyle="{StaticResource ListViewItemStyle}"> 
      <ListView.ItemTemplate> 
       <DataTemplate> 
        <usercontrols:ZoomedIn DataContext="{Binding}" /> 
       </DataTemplate> 
      </ListView.ItemTemplate> 
      <ListView.GroupStyle> 
       <GroupStyle> 
        <GroupStyle.HeaderTemplate> 
         <DataTemplate> 
          <TextBlock FontSize="20" 
            Text="{Binding CategoryName}" 
            Foreground="{ThemeResource 
            SystemControlForegroundAccentBrush}" 
            FontWeight="SemiBold" /> 
         </DataTemplate> 
        </GroupStyle.HeaderTemplate> 
       </GroupStyle> 
      </ListView.GroupStyle> 
      <Interactivity:Interaction.Behaviors> 
       <Core:EventTriggerBehavior EventName="Tapped"> 
        <Core:InvokeCommandAction 
         Command="{Binding ItemClickCommand}" 
         CommandParameter="{Binding SelectedDetail}" /> 
       </Core:EventTriggerBehavior> 
      </Interactivity:Interaction.Behaviors> 
    </ListView> 

沒有人有任何想法,爲什麼一個ListView控件將表現不同的人?

謝謝。

回答

1

該項目不突出,因爲你有Background="White"集,這種顏色永遠是高亮顏色以上。需要將UserControl背景設置爲Transparent

要使其以您想要的方式工作,您需要更改ListViewItemContainerStyle。如果您在ListView中有不同的元素,則可以使用ItemContainerStyleSelector

你可以閱讀更多關於ListViewItemhere

您所需要的變革列表視圖中的項目Background特性,例如:對

<ListView> 
    <ListView.ItemContainerStyle> 
     <Style TargetType="ListViewItem"> 
      <Setter Property="Background" Value="White"/> 
     </Style> 
    </ListView.ItemContainerStyle> 
</ListView> 
+0

現貨!我將背景顏色設置爲調試UI問題,並忘記將其從我的用戶控件中移除。非常感謝! – Thierry

相關問題