问题描述
我在gridview中使用了gridview,并希望实现鼠标滚轮的滚动功能。所以我把这个块添加到了内部的gridview中
< GridView.Template>
< ControlTemplate>
< ItemsPresenter />
< / ControlTemplate>
< /GridView.Template>
但在这种情况下,刷卡不起作用
如何解决这个问题?
第2部分。
我会试着更深入地描述这种情况。我有主屏幕,应该实现像Windows 8的主屏幕上的功能。它应该放大/缩小。这就是我使用SenaticZoom的原因。在ZoomIn中,我放置了包含控件的GridView。该控件包含自己的GridView(我需要实现滑动功能)。我不知道如何改变这个xaml文件。有什么建议么?控制代码:
< GridView
x:Name =iGridView
Margin =120,0,0,0
ItemsSource ={Binding Source = {StaticResource ViewSource}}
ItemTemplateSelector ={StaticResource ItemTemplateSelector}
IsItemClickEnabled =True
MinCellHeight =450
MinCellWidth =245
IsSwipedEnabled =True
>
< GridView.Template>
< ControlTemplate>
< ItemsPresenter />
< / ControlTemplate>
< /GridView.Template>
< GridView.ItemsPanel>
< ItemsPanelTemplate>
< VirtualizingStackPanel Orientation =Horizontal/>
< / ItemsPanelTemplate>
< /GridView.ItemsPanel>
< GridView.GroupStyle>
< GroupStyle>
< GroupStyle.HeaderTemplate>
< DataTemplate>
< Grid Margin =0,0,0,20>
Content ={Binding Title}
Style ={StaticResource Header}/>
< / Grid>
< / DataTemplate>
< GroupStyle.Panel>
< ItemsPanelTemplate>
< VariableSizedWrapGrid VerticalAlignment =TopHeight =550Orientation =Vertical/>
< / ItemsPanelTemplate>
< / GroupStyle>
< /GridView.GroupStyle>
< / GridView>
和基本页面的代码
< SemanticZoom x:Name =sZoomVerticalAlignment =Stretch>
< SemanticZoom.ZoomedInView>
< GridView x:Name =zoomInSelectionMode =None
IsItemClickEnabled =False
IsSwipeEnabled =False
>
< GridView.ItemsPanel>
< ItemsPanelTemplate>
< StackPanel Orientation =Horizontal/>
< / ItemsPanelTemplate>
< /GridView.ItemsPanel>
< GridView.ItemContainerStyle>
< Style TargetType =GridViewItem>
< Setter Property =TemplateValue ={StaticResource ItemTemplate}/>
< / style>
< /GridView.ItemContainerStyle>
< local:Control1 x:Name =Control1/>
< local:Control1 x:Name =Control2/>
< / GridView>
这是工作的GridView风格。我删除scrollviewr属性
< Style x:Key =GridViewInGridViewStyleTargetType =GridView>
< Setter Property =PaddingValue =0,0,0,10/>
< Setter Property =IsTabStopValue =False/>
< Setter Property =TabNavigationValue =Once/>
< Setter Property =IsSwipeEnabledValue =True/>
< Setter Property =ItemContainerTransitions>
< Setter.Value>
< TransitionCollection>
< AddDeleteThemeTransition />
< ContentThemeTransition />
< ReorderThemeTransition />
< EntranceThemeTransition IsStaggeringEnabled =False/>
< / TransitionCollection>
< / Setter>
< Setter Property =ItemsPanel>
< Setter.Value>
< ItemsPanelTemplate>
< WrapGrid Orientation =Vertical/>
< / ItemsPanelTemplate>
< / Setter>
< Setter Property =Template>
< Setter.Value>
< ControlTemplate TargetType =GridView>
< Border BorderBrush ={TemplateBinding BorderBrush}BorderThickness ={TemplateBinding BorderThickness}Background ={TemplateBinding Background}>
< ItemsPresenter HeaderTemplate ={TemplateBinding HeaderTemplate}Header ={TemplateBinding Header}HeaderTransitions ={TemplateBinding HeaderTransitions}Padding ={TemplateBinding Padding}/>
< / Border>
< / ControlTemplate>
< / Setter>
< / style>
I have gridview in the gridview and want to implement the mouse wheel scrolling functionality. So I added this block into the internal gridview
<GridView.Template>
<ControlTemplate >
<ItemsPresenter />
</ControlTemplate>
</GridView.Template>
But in this case swiping doesn't work
How manage I to solve this problem?
part 2.I'll try to describe this situation more deeply. I have main screen that should realize functionality like on the main screen in Windows 8. It should be zoomed in/out. That's why i use SenaticZoom. In to ZoomIn I put GridView, that contains controls. The control contain own GridView(I need to realize the swiping functionality). I don't know how change this xaml files. Any suggestions? The code of control:
<GridView
x:Name="iGridView"
Margin="120,0,0,0"
ItemsSource="{Binding Source={StaticResource ViewSource}}"
ItemTemplateSelector ="{StaticResource ItemTemplateSelector}"
IsItemClickEnabled="True"
MinCellHeight = "450"
MinCellWidth = "245"
IsSwipedEnabled="True"
>
<GridView.Template>
<ControlTemplate>
<ItemsPresenter />
</ControlTemplate>
</GridView.Template>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="0,0,0,20">
<Button
Content="{Binding Title}"
Style="{StaticResource Header}"/>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid VerticalAlignment="Top" Height="550" Orientation="Vertical"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>
and code of the base page
<SemanticZoom x:Name="sZoom" VerticalAlignment="Stretch" >
<SemanticZoom.ZoomedInView>
<GridView x:Name="zoomIn" SelectionMode="None"
IsItemClickEnabled="False"
IsSwipeEnabled="False"
>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Setter Property="Template" Value="{StaticResource ItemTemplate}"/>
</Style>
</GridView.ItemContainerStyle>
<local:Control1 x:Name="Control1" />
<local:Control1 x:Name="Control2" />
</GridView>
</SemanticZoom.ZoomedInView>
It is work GridView style. i remove scrollviewr property
<Style x:Key="GridViewInGridViewStyle" TargetType="GridView">
<Setter Property="Padding" Value="0,0,0,10"/>
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="TabNavigation" Value="Once"/>
<Setter Property="IsSwipeEnabled" Value="True"/>
<Setter Property="ItemContainerTransitions">
<Setter.Value>
<TransitionCollection>
<AddDeleteThemeTransition/>
<ContentThemeTransition/>
<ReorderThemeTransition/>
<EntranceThemeTransition IsStaggeringEnabled="False"/>
</TransitionCollection>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridView">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<ItemsPresenter HeaderTemplate="{TemplateBinding HeaderTemplate}" Header="{TemplateBinding Header}" HeaderTransitions="{TemplateBinding HeaderTransitions}" Padding="{TemplateBinding Padding}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
这篇关于Metro风格:用鼠标滚轮滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!