Closed derekantrican closed 6 months ago
I will try it.
@ChisterWu Any luck reproducing this?
@ChisterWu I can reproduce with simply this:
<TabControl>
<TabItem Header="Main">
</TabItem>
<TabItem Header="Player">
<WebView/>
</TabItem>
</TabControl>
Put that into a Window, start the application, click "Player" tab, then click "Main" tab.
I found a (horrible, but working) workaround for the above example (while referencing this post):
XAML:
<Grid RowDefinitions="Auto,*">
<TabStrip x:Name="tabStrip" SelectionChanged="TabStrip_SelectionChanged">
<TabItem Header="Main"/>
<TabItem Header="Player"/>
</TabStrip>
<WebView x:Name="webView" Grid.Row="1" IsVisible="False"/>
</Grid>
XAML.CS:
private void TabStrip_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabStrip tabStrip = sender as TabStrip;
if (tabStrip.SelectedItem != null)
{
this.FindControl<WebView>("webView").IsVisible = (tabStrip.SelectedItem as TabItem).Header as string == "Player";
}
}
For some reason I'm having trouble reproducing this with the sample in this repo. I changed SampleWebView\MainView.axaml to this:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:SampleWebView.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:SampleWebView.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SampleWebView.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="SampleWebView">
<TabControl>
<TabItem Header="Tab1"/>
<TabItem Header="Tab2">
<WebView x:Name="PART_WebView" Url="http://www.bilibili.com"/>
</TabItem>
</TabControl>
</Window>
And this is the result:
So while it doesn't crash the application, the browser doesn't show back up when the tab is navigated back to. (And I'm not sure why it doesn't crash in this test - perhaps some differences in the version of Avalonia or something)
thank for the fix
Going to assume this is closed & fixed via https://github.com/AvaloniaUI/Avalonia/pull/15029 (once this goes out with a release of Avalonia)
Screen recording (the "Pip Details for ...." is the WebView control):
Here's the exception details:
I'm on
At the moment I don't have a min repro example but if you really need one I can work on making one.