2016-11-16 4 views
0

私はListViewを持っています。マウスで行を選択すると、押している間にその行に余白や余白がありますが、何がわからないのでしょうか?キーボードで行を選択したときのような効果。ListViewItemの効果を取り除く方法は?

答えて

1

デフォルト動作を変更するには、ListViewItemのスタイルを変更する必要があります。

します。C:\ Program Files(x86の)\ Windowsのキット\ 10 \設計時\ CommonConfiguration \ニュートラル\ UAP \ 10.0.14393.0 \ジェネリック\ generic.xamlあなたはmsdn上またはローカルドライブ上のこれらのスタイルを見つけることができます

問題視覚状態は、おそらくPressedPressedSelectedです。これらのビジュアル状態を、ListViewが望むものに変更します。

<!-- Style for Windows.UI.Xaml.Controls.ListViewItem --> 
<Style TargetType="ListViewItem" x:Key="ListViewItemExpanded"> 
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" /> 
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" /> 
<Setter Property="Background" Value="Transparent"/> 
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" /> 
<Setter Property="TabNavigation" Value="Local"/> 
<Setter Property="IsHoldingEnabled" Value="True"/> 
<Setter Property="Padding" Value="12,0,12,0"/> 
<Setter Property="HorizontalContentAlignment" Value="Left"/> 
<Setter Property="VerticalContentAlignment" Value="Center"/> 
<Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/> 
<Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}"/> 
<Setter Property="UseSystemFocusVisuals" Value="True" /> 
<Setter Property="Template"> 
    <Setter.Value> 
    <ControlTemplate TargetType="ListViewItem"> 
     <Grid x:Name="ContentBorder" 
       Background="{TemplateBinding Background}" 
       BorderBrush="{TemplateBinding BorderBrush}" 
       BorderThickness="{TemplateBinding BorderThickness}"> 
     <VisualStateManager.VisualStateGroups> 
      <VisualStateGroup x:Name="CommonStates"> 
      ... 
      <VisualState x:Name="Pressed"> 
       <Storyboard> 
       <DoubleAnimation Storyboard.TargetName="BorderBackground" 
           Storyboard.TargetProperty="Opacity" 
           Duration="0" 
           To="1"/> 
       <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill"> 
        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListMediumBrush}" /> 
       </ObjectAnimationUsingKeyFrames> 
       <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" /> 
       </ObjectAnimationUsingKeyFrames> 
       <PointerDownThemeAnimation TargetName="ContentPresenter" /> 
       </Storyboard> 
      </VisualState> 
      ... 
      <VisualState x:Name="PressedSelected"> 
       <Storyboard> 
       <DoubleAnimation Storyboard.TargetName="MultiSelectCheck" 
           Storyboard.TargetProperty="Opacity" 
           Duration="0:0:0" 
           To="1"/> 
       <DoubleAnimation Storyboard.TargetName="BorderBackground" 
           Storyboard.TargetProperty="Opacity" 
           Duration="0" 
           To="1"/> 
       <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill"> 
        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListAccentHighBrush}" /> 
       </ObjectAnimationUsingKeyFrames> 
       <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground"> 
        <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" /> 
       </ObjectAnimationUsingKeyFrames> 
       <PointerDownThemeAnimation TargetName="ContentPresenter" /> 
       </Storyboard> 
      </VisualState> 
      </VisualStateGroup> 
      ... 
+0

私はすべてのコードを持っていますか?私はちょうど押されたブロックを持っていくことができますか(私が変更したいブロック)? – Maryam

+0

これはブロックなので、 'Setter Property =" Template "'の下にあるものすべてを持ってきてください。 – Bart

+0

さらに詳しい情報が必要な場合は、スタイルやテンプレートの詳細をご覧ください。https://msdn.microsoft.com/en-us/library/ee230084(v=vs.110).aspx – Bart

関連する問題