How to use WebView Controls inside a FlipView correctly using WPF and C#?


(Yay) #1

I am trying to make a FlipView for which the items (Views) will be in the form of WebViews, so that i can FlipView through Web pages.

The flipping should be done horizontally (left to right / right to left), but so far i fail to do that, here is my current XAML code:

<FlipView Grid.Column="3" Grid.Row="0" Grid.RowSpan="5" Name="MainFlipView">
    <WebView Source="" Width="825" Height="500" />
    <WebView Source="" Width="825" Height="500" />
    <WebView Source="" Width="825" Height="500" />

But unfortunately the WebViews take over mouse actions, and the FlipView doesn’t interact to my mouse dragging.

What should i do? do i have to make a custom WebView Element?

( #2

I don’t know what you missed up, but the same xaml code works in my machine (visual studio 2015). double check it.

(Yassine) #3

I did the following xaml code in my Universal Windows App project and worked perfect :

        <local:WebsiteCollection x:Key="WebsiteCollection">
            <local:Website Url="" />
            <local:Website Url="" />
            <local:Website Url="" />
            <local:Website Url="" />
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <FlipView x:Name="FlipViewControl" ItemsSource="{StaticResource WebsiteCollection}" HorizontalContentAlignment="Center">
                    <StackPanel Orientation="Horizontal" />
                        <WebView Source="{Binding Url}" />

That’s the full XAML code for the Universal Windows App Page, that contains the FlipView. the WebView Control is used inside the DataTemplate of the FlipViewItem. The FlipView Items are bound from the WebsiteCollection Resource, don’t worry it’s not something tricky only a simple class that has only one member named Url. that Url is bound to the WebView Source. so the WebView website pages will get loaded automatically.

using the StackPanel for the ItemsPanelTemplate of the FlipView is necessary to get the effect of swiping the pages left-to-right and right-to-left.

That’s it, i hope that helps someone else.