locked
FlipView event for "flip"start RRS feed

  • Question

  • Hello
    I have a FlipView that contains WebView in FlipViewItem. Unfortunately this scenario is not supported. (WebView cann't be overlapped)

    I would like to convert the WebView to WebViewBrush once the User starts "flip" to another page (and collaps the WebView). This should enable WebView flipping.

    What FlipView event should i subscribe to be notified about "flip"start (when flipviewitem begins to slide to another one)? In this event then i can convert the WebView to WebViewBrush.

    Thanks

    peter

    Friday, October 18, 2013 4:12 PM

Answers

  • Hi,

    You can contain a WebView control in FlipView. That work fine in my computer. You can refer to

    some codes below:

    In XAML:

     <Page.Resources>
            <local:BoolToVisibilityConverter x:Key="BTVConverter"/>
        </Page.Resources>
        <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <FlipView Name="fv" Grid.Column="1">
                <FlipViewItem Name="item1">
                    <WebView Visibility="{Binding ElementName=item1, Path=IsSelected, Converter={StaticResource BTVConverter}}" Source="Http://www.baidu.com" Height="400" Width="400"/>
                </FlipViewItem>
                <FlipViewItem Name="item2">
                    <WebView Visibility="{Binding ElementName=item2, Path=IsSelected, Converter={StaticResource BTVConverter}}" Source="http://www.google.com" Height="400" Width="400"/>
                </FlipViewItem>
            </FlipView>
        </Grid>

    In code-behind:

     public class BoolToVisibilityConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, string language)
            {
                var v = (bool)value;
                if (v)
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            public object ConvertBack(object value, Type targetType, object parameter, string language)
            {
                throw new NotImplementedException();
            }
        }

    The code above works fine when you flip or swipe the FlipView and the WebView can display the

    url content.

    Also, if you want to notified about "flip"start , you can refer to FlipView SelectionChanged event:

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.selector.selectionchanged.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Monday, October 21, 2013 2:23 AM from
    • Marked as answer by this_peter Monday, October 21, 2013 1:12 PM
    Monday, October 21, 2013 2:22 AM

All replies

  • Hi,

    You can contain a WebView control in FlipView. That work fine in my computer. You can refer to

    some codes below:

    In XAML:

     <Page.Resources>
            <local:BoolToVisibilityConverter x:Key="BTVConverter"/>
        </Page.Resources>
        <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <FlipView Name="fv" Grid.Column="1">
                <FlipViewItem Name="item1">
                    <WebView Visibility="{Binding ElementName=item1, Path=IsSelected, Converter={StaticResource BTVConverter}}" Source="Http://www.baidu.com" Height="400" Width="400"/>
                </FlipViewItem>
                <FlipViewItem Name="item2">
                    <WebView Visibility="{Binding ElementName=item2, Path=IsSelected, Converter={StaticResource BTVConverter}}" Source="http://www.google.com" Height="400" Width="400"/>
                </FlipViewItem>
            </FlipView>
        </Grid>

    In code-behind:

     public class BoolToVisibilityConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, string language)
            {
                var v = (bool)value;
                if (v)
                {
                    return Visibility.Visible;
                }
                return Visibility.Collapsed;
            }
            public object ConvertBack(object value, Type targetType, object parameter, string language)
            {
                throw new NotImplementedException();
            }
        }

    The code above works fine when you flip or swipe the FlipView and the WebView can display the

    url content.

    Also, if you want to notified about "flip"start , you can refer to FlipView SelectionChanged event:

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.selector.selectionchanged.aspx

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    • Edited by Anne Jing Monday, October 21, 2013 2:23 AM from
    • Marked as answer by this_peter Monday, October 21, 2013 1:12 PM
    Monday, October 21, 2013 2:22 AM
  • Hi 

    Got it.

    It actually makes Problems only in Windows 8 not 8.1

    For Windows 8 i found the following Solution:

    Edit FlipView Template and find the ScrollViewer. In ScrollViewer subscribe for ViewChanged event.

    When ViewChanged event Property IsIndeterminate is true, the user "flips" and the WebView should be "frozen" to WebViewBrush.

    Monday, October 21, 2013 1:12 PM