[英]How to disable the scrollview in LongListSelector in windows phone 7
我想在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滾動到頂部,則上述堆棧面板也應滾動到頂部。
您可以通過將LongListSelector(LLS)的高度設置為大於所有項目的高度來禁用滾動。 您可以為LLS設置最大高度以避免滾動。
在ScrollViewer中使用LLS並不是一個好習慣,因為兩個滾動都將為它們的輸入事件而戰,並且結果將不符合預期。
另外,為了更專注於您的問題,您可以將StackPanels添加到LLS的ListHeader
中,這樣,當您滾動LLS時,StackPanels也將與您的項一起滾動。
使用LLS的ListHeader
的示例結構為:
<phone:LongListSelector>
<phone:LongListSelector.ListHeader>
<StackPanel>
<StackPanel Name="Panel1"></StackPanel>
<StackPanel Name="Panel2"></StackPanel>
</StackPanel>
</phone:LongListSelector.ListHeader>
</phone:LongListSelector>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.