question

Nimalika-6845 avatar image
0 Votes"
Nimalika-6845 asked ·

UWP Web view get blinks one time after loading

How can we fix web view blink issue?

XAML code

 util:WebViewCustomProperties.HtmlContent="{Binding CourseDescription}"

WebViewCustomProperties Class

 // "HtmlContent" attached property for a WebView        
         
 public static readonly DependencyProperty HtmlContentProperty =
            DependencyProperty.RegisterAttached("HtmlContent", typeof(string), typeof(WebViewCustomProperties), new PropertyMetadata("", OnHtmlHtmlContentChanged));
    
    
 // Getter and Setter        
         
 public static string GetHtmlContent(DependencyObject obj) { return (string)obj.GetValue(HtmlContentProperty); }
         
 public static void SetHtmlContent(DependencyObject obj, string value) { obj.SetValue(HtmlContentProperty, value); }
    
    
  // Handler for property changes in the DataContext : set the WebView        
         
 private static void OnHtmlHtmlContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
             WebView wv = d as WebView;
             if (wv != null)
             {
                 wv.NavigateToString((string)e.NewValue);
             }
         }

Issue Video

web view blink issue


windows-uwpwindows-uwp-xaml
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichardZhang-MSFT avatar image
0 Votes"
RichardZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

WebView page blink may be an animation issue. You can try to disable the transition animation between pages to solve.

 MyFrame.Navigate(typeof(WebViewPage), null, new SuppressNavigationTransitionInfo());



If you like page animation, you can try another method:

Create the WebView in code-behind

 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     view = new WebView(WebViewExecutionMode.SameThread);
     MyGrid.Children.Add(view);
     var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/MyPage.html"));
     string content = await FileIO.ReadTextAsync(file);
     view.NavigateToString(content);
 }

It can also fix the problem of page blink, you can choose as needed.

Thanks

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Disabling the transition animation fixed the issue. Thank you very much.

0 Votes 0 · ·