'How to change content TabViewItem? UWP XAML WPF
I have a TabView element. My task is to change the content of a tab to a Webview. Initially, a Page is installed there as the content. After changing the content of the TabViewItem, the WebView element is not displayed, and appears only after switching tabs. How can I make it so that after changing the Content property, the WebView element immediately starts to be displayed, and not just after switching tabs?

public void SearchWebFromStartPage(string url)
{
var newWebView = new WebView(WebViewExecutionMode.SeparateProcess);
WebViewStates.Add(newWebView, true);
newWebView.NavigationCompleted += browser_NavigationCompleted;
newWebView.NewWindowRequested += browser_NewWindowRequested;
newWebView.NavigationStarting += browser_NavigationStarting;
newWebView.ContainsFullScreenElementChanged += webView_ContainsFullScreenElementChanged;
newWebView.Navigate(new Uri(url));
CurrentSelectedTab.Content = newWebView; //Here I set the WebView element as the TabViewItem content, but the WebView is not displayed.
}
public void GridViewItemTappedCommand_Executed(object obj)
{
if (GridViewSelectedItem != null)
{
MainPage.SearchWebFromStartPage(GridViewSelectedItem.Url);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
