【发布时间】:2015-02-26 07:06:38
【问题描述】:
我想禁用 LongListSelector 中的滚动视图。
我试过这样:
<toolkit:LongListSelector x:Name="List_Contacts"
IsFlatList= "False"
DisplayAllGroups="False"
Margin="0,0,0,100"
Width="480"
Background="Transparent"
ItemsSource="{Binding ResultList}"
ItemTemplate="{StaticResource ItemTemplate}"
GroupHeaderTemplate="{StaticResource GroupItemHeaderTemplate}"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Tap="List_Contacts_Tap"/>
但是这里的滚动没有被禁用。
我从堆栈溢出中找到了一种解决方案
<Style x:Key="LongListSelectorWithNoScrollBarStyle" TargetType="toolkit:LongListSelector">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="phone:LongListSelector">
<Grid Background="{TemplateBinding Background}" d:DesignWidth="480" d:DesignHeight="800">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ScrollStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.5"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Scrolling" />
<VisualState x:Name="NotScrolling"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid Margin="{TemplateBinding Padding}">
<ViewportControl x:Name="ViewportControl"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Top"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
但是这里我遇到了错误
找不到类型“ViewportControl”。确认您没有丢失程序集引用,并且所有引用的程序集都已构建。
我也将命名空间包含在 xaml 中。
xmlns:ViewportControl="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows"
但现在我仍然收到'ViewportControl' was not found 错误。
请帮我禁用 LLS 中的滚动。
这里所有元素都是可滚动的。LLS 将有 N 个项目。如果我将 LLS 滚动到上面的堆栈面板也应该滚动到顶部。
【问题讨论】:
-
为什么要禁用滚动?你不能使用 IsHitTestVisible 属性吗?
-
@Pradeep.. 我也想写点击事件。所以我不能使用这个 IsHitTestVisible .. 我的要求就是这样。这就是为什么我这样问..
-
解释为什么要禁用滚动?
标签: c# xaml windows-phone-7 longlistselector