如何去除双卷轴。 xaml uwp 中 ScrollViewer 中的 WebView

How to remove double scroll. WebView in ScrollViewer in xaml uwp

我尝试在 uwp 中创建页面。我想要 一些元素和 WebView。如何避免双滚动(一个在整个 ScrollViewer 上,第二个在 WebView 上)?我只想在 ScrollViewer 上滚动。

我的xaml代码

    <ScrollViewer>

            <StackPanel Name="NewsInformation" Margin="5,0,5,0">
                <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Height="Auto">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="150" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>


                    <Image Source="{Binding Image,Converter={StaticResource ImageShow}}" Grid.Row="0" Stretch="UniformToFill" />
                    <!--<Canvas Canvas.ZIndex="1000" Grid.Row="0">-->
                    <!--<TextBlock Text="{Binding Title}" VerticalAlignment="bottom" TextWrapping="Wrap"  Foreground="red" />-->
                    <StackPanel Grid.Row="0" VerticalAlignment="bottom" Background="#cc000000" Padding="10">
                        <TextBlock Text="{Binding SneakPeak}" TextWrapping="Wrap"  MaxLines="2" FontSize="15" Foreground="#ffffff" />
                    </StackPanel>
                    <!--</Canvas>-->
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Top" Grid.Row="1" Margin="10, 10, 10, 5">
                        <TextBlock Text="{Binding CreationDate}" Foreground="#595959" TextWrapping="Wrap" FontSize="7"/>
                        <TextBlock Text="|" Margin="5,0,5,0" Foreground="#595959" FontSize="7"/>
                        <TextBlock Text="{Binding Author.Name}" Foreground="#595959" FontSize="7"/>
                        <TextBlock Text="{Binding Author.Surname}" Foreground="#595959" Margin="3,0,0,0" FontSize="7"/>
                    </StackPanel>
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top" Grid.Row="2" Margin="10, 0, 10, 20">
                        <TextBlock Text="{Binding Title}" HorizontalAlignment="Stretch" FontSize="12" TextWrapping="Wrap" Margin="0, 0, 0, 10" VerticalAlignment="Top" FontWeight="Bold"/>
                        <!--<TextBlock Text="{Binding Content}" HorizontalAlignment="Stretch"  TextWrapping="Wrap" VerticalAlignment="Top"  FontSize="10"/>-->
                        <WebView x:Name="newsContent" Height="400"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                    </StackPanel>
                </Grid>
        </StackPanel>
    </ScrollViewer>

我想显示 WebView 中的所有内容 html 并在所有页面上滚动一次。

这不能在 XAML 中完成。 您可以通过修改 HTML 内容本身来实现。例如,您可以通过在 HTML 页面中声明以下正文来删除垂直滚动条:

<body style="overflow-y: hidden">....</body>

您也可以在页面加载后注入脚本以禁用滚动条。

myWebView.NavigateToString("<html><body>my very long content</body></html>");
myWebView.LoadCompleted += async (s, args) => await myWebView.InvokeScriptAsync("eval", new string[] { "document.body.style.overflowY='hidden'" });