CommunityToolkit / Microsoft.Toolkit.Win32

ARCHIVE - This repository contained XAML Islands wrapper controls and tooling for XAML Islands with WinUI 2, see readme for more info about XAML Islands with WinUI 3 and the WindowsAppSDK.
https://aka.ms/windowsappsdk
Other
384 stars 89 forks source link

DesktopWindowXamlSource window in taskbar in Windows10 while using WindowsXamlHostElement with CaptureElement #354

Open Eugen00-00 opened 1 year ago

Eugen00-00 commented 1 year ago

Describe the bug

I see DesktopWindowXamlSource window in taskbar in Windows10 after a dialog with WindowsXamlHostElement and CaptureElement as a WindowsXamlHostElement child is closed. There is a test WPF application. Main window contains only a buttton that opens another dialog. This dialog has olny WindowsXamlHostElement

  <Grid>
        <xamlhost:WindowsXamlHost x:Name="XamlHost1" />
</Grid>

or with InitialTypeName (it makes no difference)

  <Grid>
        <xamlhost:WindowsXamlHost x:Name="XamlHost1" InitialTypeName="Windows.UI.Xaml.Controls.CaptureElement"/>
</Grid>

In the dialog constructor: XamlHost1.Child = new CaptureElement();

Optionally it can be done (it makes no difference)

XamlHost1.ChildChanged += XamlHost_ChildChanged;
...
//closed event handler
 private void OnDialogClosed(object sender, EventArgs e)
        {
            XamlHost1.Child = null;
        }

       private void XamlHost_ChildChanged(object sender, EventArgs e)
        {
            var xh = sender as WindowsXamlHost;
            if(xh != null && !xh.IsDisposed)
            {
               xh.Dispose();
            }
        }

On button press the dialog appears, after dailog is closed one can see a DesktopWindowXamlSource window in taskbar. It is reproducible on Windows10 22H2, but not reproducible on Windows11.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

I don't want to see DesktopWindowXamlSource window in taskber after dialog is closed.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

NuGet Package(s): 
<packages>
  <package id="Microsoft.Toolkit.UI.XamlHost" version="6.1.2" targetFramework="net472" />
  <package id="Microsoft.Toolkit.Win32.UI.SDK" version="6.1.2" targetFramework="net472" />
  <package id="Microsoft.Toolkit.Win32.UI.XamlApplication" version="6.1.2" targetFramework="net472" />
  <package id="Microsoft.Toolkit.Wpf.UI.XamlHost" version="6.1.2" targetFramework="net472" />
  <package id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" targetFramework="net472" />
  <package id="System.Runtime.WindowsRuntime" version="4.6.0" targetFramework="net472" />
  <package id="System.Runtime.WindowsRuntime.UI.Xaml" version="4.6.0" targetFramework="net472" />
</packages>

Package Version(s): 
Microsoft.Toolkit.Wpf.UI.XamlHost v. 6.1.2
Microsoft.Windows.SDK.Contracts v. 10.0.18362.2005

Project .NET Version:
- [x ] .NET Framework (version:  4.7.2)
- [ ] .NET Core 3
- [ ] .NET Core 3.1 Preview (version: )

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] Insider Build (build number: )
- [ ] Windows10 22H2

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [ ] Insider Build (xxxxx)

Device form factor:
- [ ] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ x] 2019 (version: 16.11.24) 
- [ ] 2019 Preview (version: )

Additional context

Add any other context about the problem here.

ghost commented 1 year ago

Hello Eugen00-00, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌