2015-05-24 67 views
4

我的Windows Store應用程序中有一個ListView。我希望它成爲一個靜態列表(我使用它是因爲它支持虛擬化,但如果我應該使用其他的東西,請告訴我!)。我設法通過鼠標懸停等方式禁用了大部分UI更改。但是,我還沒有想到如何做的一件事是刪除點擊行爲。當你點擊一個項目時,它會縮小一點,以反饋它已被點擊的信息。我該如何解決這個問題?ListView - 禁用鼠標停止行爲

這裏是我的ListView的XAML:

<ListView x:Name="SlideStrip" 
       SelectionMode="None" 
       ScrollViewer.HorizontalScrollMode="Auto" 
       ScrollViewer.HorizontalScrollBarVisibility="Auto" 
       ScrollViewer.VerticalScrollBarVisibility="Disabled" 
       ItemContainerStyle="{StaticResource PlainOldList}"> 
     <ListView.ItemsPanel> 
      <ItemsPanelTemplate> 
       <ItemsStackPanel Orientation="Horizontal"/> 
      </ItemsPanelTemplate> 
     </ListView.ItemsPanel> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
       <local:PDFPageUserControl 
         Margin="0 0 5 0" 
         ViewModel="{Binding}" 
         RespectRenderingDimension="Vertical" /> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
    </ListView> 

的PlainOldList風格如下:

<Style x:Key="PlainOldList" TargetType="ListViewItem"> 
     <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/> 
     <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/> 
     <Setter Property="Background" Value="Transparent"/> 
     <Setter Property="TabNavigation" Value="Local"/> 
     <Setter Property="IsHoldingEnabled" Value="True"/> 
     <Setter Property="Margin" Value="0,0,0,0"/> 
     <Setter Property="HorizontalContentAlignment" Value="Left"/> 
     <Setter Property="VerticalContentAlignment" Value="Top"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ListViewItem"> 
        <ListViewItemPresenter x:Name="listViewItemPresenter" 
         CheckHintBrush="{ThemeResource ListViewItemCheckHintThemeBrush}" 
         CheckBrush="{ThemeResource ListViewItemCheckThemeBrush}" 
         ContentMargin="0" 
         ContentTransitions="{TemplateBinding ContentTransitions}" 
         CheckSelectingBrush="{ThemeResource ListViewItemCheckSelectingThemeBrush}" 
         DragForeground="{ThemeResource ListViewItemDragForegroundThemeBrush}" 
         DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}" 
         DragBackground="{ThemeResource ListViewItemDragBackgroundThemeBrush}" 
         DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}" 
         FocusBorderBrush="{ThemeResource ListViewItemFocusBorderThemeBrush}" 
         HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
         Padding="{TemplateBinding Padding}" 
         PointerOverBackgroundMargin="0" 
         PlaceholderBackground="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}" 
         ReorderHintOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" 
         SelectedPointerOverBorderBrush="{ThemeResource ListViewItemSelectedPointerOverBorderThemeBrush}" 
         SelectionCheckMarkVisualEnabled="True" 
         SelectedForeground="{ThemeResource ListViewItemSelectedForegroundThemeBrush}" 
         SelectedPointerOverBackground="{ThemeResource ListViewItemSelectedPointerOverBackgroundThemeBrush}" 
         SelectedBorderThickness="{ThemeResource ListViewItemCompactSelectedBorderThemeThickness}" 
         SelectedBackground="{ThemeResource ListViewItemSelectedBackgroundThemeBrush}" 
         VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"> 
        </ListViewItemPresenter> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 

我敢相信什麼,我需要做的就是編輯可視狀態的項容器樣式。但是對於什麼樣的視覺狀態我完全喪失了。在混合中單擊它們從不顯示活動的轉換。我試圖設置一個或兩個顯式爲零,但失敗(可能是因爲我不知道如何覆蓋默認行爲或選擇錯誤的狀態)。

任何幫助表示讚賞!

回答

3

請參閱ListViewItemExpanded樣式與所有視覺狀態。 我刪除了所有不必要的東西

<Style TargetType="ListViewItem" x:Key="ListViewItemWithoutEffectStyle"> 
     <Setter Property="HorizontalAlignment" Value="Stretch"/> 
     <Setter Property="VerticalAlignment" Value="Stretch"/> 
     <Setter Property="HorizontalContentAlignment" Value="Stretch"/> 
     <Setter Property="VerticalContentAlignment" Value="Stretch"/> 
     <Setter Property="Template"> 
      <Setter.Value> 
       <ControlTemplate TargetType="ListViewItem"> 
        <Border x:Name="OuterContainer" RenderTransformOrigin="0.5,0.5"> 
         <VisualStateManager.VisualStateGroups> 
          <VisualStateGroup x:Name="CommonStates"> 
           <VisualState x:Name="Normal" /> 
           <VisualState x:Name="Pressed"/> 
           <VisualState x:Name="CheckboxPressed"/> 
           <VisualState x:Name="Disabled"/> 

          </VisualStateGroup> 
          <VisualStateGroup x:Name="SelectionStates"> 
           <VisualState x:Name="Unselected" /> 
           <VisualState x:Name="Selected"/> 
           <VisualState x:Name="SelectedUnfocused"/> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="DataVirtualizationStates"> 
           <VisualState x:Name="DataAvailable" /> 
           <VisualState x:Name="DataPlaceholder"/> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="MultiSelectStates"> 
           <VisualState x:Name="NoMultiSelect" /> 
           <VisualState x:Name="ListMultiSelect"/> 
           <VisualState x:Name="GridMultiSelect"/> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="ReorderModeStates"> 
           <VisualState x:Name="ReorderEnabled"/> 
           <VisualState x:Name="Reorderable"/> 
           <VisualState x:Name="ReorderDisabled" /> 
          </VisualStateGroup> 
          <VisualStateGroup x:Name="ReorderHintStates"> 
           <VisualState x:Name="NoReorderHint" /> 
           <VisualState x:Name="BottomReorderHint"/> 
           <VisualState x:Name="RightReorderHint"/> 
           <VisualState x:Name="TopReorderHint"/> 
           <VisualState x:Name="LeftReorderHint"/> 
          </VisualStateGroup> 
         </VisualStateManager.VisualStateGroups> 
         <Grid x:Name="ReorderHintContent" Background="Transparent"> 
          <Border x:Name="ContentContainer"> 
           <Border x:Name="ContentBorder" 
             Background="{TemplateBinding Background}" 
             BorderBrush="{TemplateBinding BorderBrush}" 
             BorderThickness="{TemplateBinding BorderThickness}"> 
            <Grid> 
             <ContentPresenter x:Name="contentPresenter" 
                  ContentTransitions="{TemplateBinding ContentTransitions}" 
                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                  Content="{TemplateBinding Content}" 
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
                  Margin="{TemplateBinding Padding}" /> 
            </Grid> 
           </Border> 
          </Border> 
         </Grid> 
        </Border> 
       </ControlTemplate> 
      </Setter.Value> 
     </Setter> 
    </Style> 
+0

不錯!謝謝!!似乎工作。將在進一步測試後報告! – Gordon