我有我的一个的MainPage的ScrollViewer包含所有其他元素(当然,除了AppBars)。 滚动工作正常,但我想禁用捕捉行为(拖动整个页面的左侧,释放它,它会弹回)。 看到图像(ScrollViewer中的背景:黑色,电网的背景:白色)。 那么,如何可以禁用此行为? 也被称为反弹时或反弹的效果。
我只是发现了约IsScrollInertiaEnabled,但这种设置为false于事无补。
<ScrollViewer VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Disabled"
HorizontalScrollBarVisibility="Visible"
ZoomMode="Disabled"
HorizontalSnapPointsType="None"
VerticalSnapPointsType="None"
ZoomSnapPointsType="None">
<VisualStateManager>...</VisualStatemanager>
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
...
<!-- My content grid -->
</Grid>
</ScrollViewer>
对不起你的意思误解了。张贴一些额外的XAML,如果你可以...的ScrollViewer容器XAML可以帮助
尝试这样的事情
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Back button and page title -->
...
<!-- My content grid -->
<ScrollViewer Grid.Row="1"
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Disabled"
HorizontalScrollBarVisibility="Visible"
ZoomMode="Disabled"
HorizontalSnapPointsType="None"
VerticalSnapPointsType="None"
ZoomSnapPointsType="None">
// put your content here directly or in a grid
</ScrollViewer>
<VisualStateManager>...</VisualStatemanager>
</Grid>
为了解决滚动查看器中的对象的问题设定高度,让说..如果你有一个堆栈面板,设置身高=“2000”否则......和DONE。 注意:不要把任何高度,滚动浏览器。
我有其他的建议,我都面临着类似的问题,但我想禁用反弹,当时只有1元是在flipview。
所以我这样做:
创建一个TemplatedControl:
CustomFlipView并从FlipView继承:
public sealed class CustomFlipView : FlipView
接下来,我编辑的FlipViewStyle得到FlipView的样式代码(是啊,那么大的一个)。
和复制粘贴到Generic.xaml,到产生
<Style TargetType="local:CustomFlipView">
所以这给了我一个机会,名称添加到这样的XAML控制,在默认情况下没有命名。
我添加了一个名字ItemsPresenter:
<ScrollViewer x:Name="ScrollingHost" AutomationProperties.AccessibilityView="Raw" BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalSnapPointsType="MandatorySingle" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsTabStop="False" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}" IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" Padding="{TemplateBinding Padding}" TabNavigation="{TemplateBinding TabNavigation}" VerticalSnapPointsType="MandatorySingle" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled">
<ItemsPresenter x:Name="FlipViewItemsPresenter"/>
</ScrollViewer>
接下来在CustomFlipView的代码我这样做:
public sealed class CustomFlipView : FlipView //this line is indented.
{
private ItemsPresenter itemsPresenter;
public CustomFlipView()
{
this.DefaultStyleKey = typeof(CustomFlipView);
}
protected override void OnApplyTemplate()
{
base.OnApplyTemplate();
itemsPresenter = GetTemplateChild("FlipViewItemsPresenter") as ItemsPresenter;
FixateItems();
}
protected override void OnItemsChanged(object e)
{
base.OnItemsChanged(e);
FixateItems();
}
private void FixateItems()
{
if (itemsPresenter != null)
{
if (this.Items.Count < 2)
{
itemsPresenter.ManipulationMode = ManipulationModes.None;
}
else
{
itemsPresenter.ManipulationMode = ManipulationModes.System;
}
}
}
}
希望这可以给你一个提示。