none
UWP - XAML WebView Move : Prevent Interaction RRS feed

  • Question

  • Hi there,

    I'm trying to disable User interaction on a Webview inside my UWP (C#) Application, the goal is for the user to be able to drag/move the Control containing my WebView to the place he wants.
    The Manipulation is at Parent Level (on a Grid) and works fine as long as no Webview is present inside it. 
    But whenever the Webview is there and Visible, I'm out of luck moving the Control...

    I tried to overlap WebView with another Grid containing a Rectangle to see if moving the Rectangle (above my webview) would make my Control move, and although this rectangle completely covers my WebView the result is the same, no move.
    (If I set the WebView Visibility to Collapsed the Control can move by interacting with the Rectangle)

    Seems like whatever I do, the webview is receiving the input preventing my Control to move ? 

    Here are some things I tried on Webview : 
    IsHitTestVisible="False"  AllowFocusOnInteraction="False" IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False"  
    I would have thought one option could have make The Webview 

    Would you please have an idea of how I could disable completely my WebView (preventing user interaction with it) thus enabling my Control to move?
    Many thanks in advance for your help!

    Best regards,

    Eric 

     
    Saturday, February 9, 2019 12:07 PM

All replies

  • Hello Eric,

    I've put a panel and then set its candrag and border thickness property. The code is simple:

    <RelativePanel BorderThickness="3" BorderBrush="Blue" CanDrag="True" Width="500" Height="500">
                <WebView Width="300" Height="300" Source="https://www.microsoft.com">
    
                </WebView>
                <Button Content="test" Width="50" Height="50"/>
            </RelativePanel>

    The result is that I can drag the panel by drag the border. So it means I cannot reproduce your issue. Can you show us your code first?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 11, 2019 9:19 AM
    Moderator
  • Dear Barry,

    Many thanks for your quick reply and help!

    In fact my goal is to Drag the WebView when user clicks inside it not only selecting the border (the user has no other potential interaction than dragging or resizing the View ) 
    The webview is only used to render dynamic SVG image, so the WebView should act as an image, you would tell me why don't  you use a simple image with SvgImageSource? And  the answer is that, sadly, SvgImageSource does not render <text /> from SVG files whereas WebView does....
    Currenlty I'm using Manipulator_OnManipulationDelta for moving and resizing my UserControl (Viewbox) which works fine with any other control but the webview.
    Tried a bunch of things.. below is to give you an idea about hierarchy :

    <Grid  ManipulationMode="TranslateX,TranslateY" Background="Aqua"
          ManipulationStarted="Manipulator_OnManipulationStarted"
          ManipulationDelta="Manipulator_OnManipulationDelta">
            <Viewbox>
                <Grid IsHitTestVisible="False"  AllowFocusOnInteraction="False"  IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False"  >
                     <WebView x:Name="webView" Height="400px" Width="400px" IsHitTestVisible="False"  AllowFocusOnInteraction="False" DefaultBackgroundColor="Transparent" 
                      NavigationCompleted="WebView_NavigationCompleted" 
                             IsDoubleTapEnabled="False" IsHoldingEnabled="False" IsRightTapEnabled="False" IsTapEnabled="False"  
                      ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollMode="Disabled"   />
                </Grid>
            </Viewbox>
    </Grid>


    Many thanks Barry for your appreciated suggestions!

    Best regards,
    Eric

    Monday, February 11, 2019 3:57 PM
  • If you want the WebView to be complete static then use a WebViewBrush.
    Tuesday, February 12, 2019 5:21 AM
  • Hi Rob,

    Thanks a lot, I ignored about WebViewBrush.

    I'll give it a try,
    Best,Eric

    Tuesday, February 12, 2019 9:51 AM