Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Xaml Islands do not work when Microsoft.Toolkit.Uwp.UI.Animations is referenced by UWP Class Library #159

Closed
hansmbakker opened this issue Jul 31, 2019 · 8 comments

Comments

@hansmbakker
Copy link

hansmbakker commented Jul 31, 2019

I'm submitting a...

Current behavior

Project fails to start when Microsoft.Toolkit.Uwp.UI.Animations version 5.1.1 is referenced by the User Control class library. Exception message:

System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Toolkit.Uwp.UI.Animations, Version=5.1.0.0, Culture=neutral, PublicKeyToken=null'.

Expected behavior

UWP Class Library containing User Control that uses Microsoft.Toolkit.Uwp.UI.Animations can be referenced by Winforms project using Xaml Islands.

Minimal reproduction of the problem with instructions

Project setup:

  • Winforms on netcore3.0 (preview 7) project
  • app references a UWP Class Library containing user controls
  • Winforms project manually set to x64 platform
  • User Control containing implicit animation xaml:
<animations:Implicit.ShowAnimations>
   <animations:OpacityAnimation Duration="0:0:1" From="0" To="1.0"> 
   </animations:OpacityAnimation>
</animations:Implicit.ShowAnimations>

<animations:Implicit.HideAnimations>
   <animations:ScalarAnimation Target="Opacity" Duration="0:0:1" To="0.0"> 
   </animations:ScalarAnimation>
</animations:Implicit.HideAnimations>

Environment

Nuget Package(s): Microsoft.Toolkit.Forms.UI.XamlHost

Package Version(s): 6.0-preview7

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [x] Insider Build (18362)

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

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

Visual Studio 
- [x] 2019 16.3 Preview 1

@azchohfi
Copy link
Contributor

This is a docs issue on https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/wpf-winforms/windowsxamlhost#add-a-custom-uwp-control
We are already aware. Most of these issues were fixed on 6.0.0-preview7, and updated docs should go out soon.

@azchohfi
Copy link
Contributor

Let me know if these steps help:

  1. Add a Blank App (Universal Windows) project to the solution (UWP App, NOT class library or Windows runtime component)
  2. In the UWP project:
    • Install Microsoft.Toolkit.Win32.UI.XamlApplication package (preview 7).
    • In App.xaml, replace the default XAML with the following to derive the App class from XamlApplication.
<Toolkit:XamlApplication
    x:Class="MyUWPApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:Toolkit="using:Microsoft.Toolkit.Win32.UI.XamlHost"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyUWPApp">
</Toolkit:XamlApplication>
  1. In App.xaml.cs, make App class public, remove the inheritance from Application, call this.Initialize() before this.InitializeComponent(), and delete OnLaunched override method.
  2. Add anything you want/need to share with the WPF project inside this UWP project.
  3. In the WPF project:
    • Install Microsoft.Toolkit.Wpf.UI.XamlHost package (preview 7).
    • Reference the UWP project.
    • Add the XAML Island

@hansmbakker
Copy link
Author

hansmbakker commented Jul 31, 2019

@azchohfi Thank you for your help! Animations work now. I gave more feedback on the above implementation steps in #151.

I didn't see 'Acrylic backdrop background not working on Xaml Islands' listed as a known issue, is that internally known to your team? Even when I make the following components transparent, it ends up as black instead of transparent:

  • custom UWP user control
  • XamlApplication MainPage
  • WPF host window

Would I need to report it as a bug?

@azchohfi
Copy link
Contributor

That's a tricky one. @ocalvo, do you happen to know if a Xaml Island can be made transparent?
Maybe it's easier in a C++/Win32 app... Anyway, @hansmbakker, I would start a different issue.

@azchohfi
Copy link
Contributor

PS: @hansmbakker did this fix everything else for you?

@hansmbakker
Copy link
Author

@azchohfi I got the rest working so this can be closed.

One point is that it seems that you manually have to rebuild the dependencies and the wpf host after changing something in the dependencies (the XamlApplication project). If you change something in it then the wpf host doesn't immediately pick it up and rebuild everything. However that is something that you are probably still working on?

I'll open a separate issue for the Acrylic.

@hansmbakker
Copy link
Author

@azchohfi Acrylic / transparency issue reported as #160

@hansmbakker
Copy link
Author

hansmbakker commented Aug 2, 2019

One point is that it seems that you manually have to rebuild the dependencies and the wpf host after changing something in the dependencies (the XamlApplication project). If you change something in it then the wpf host doesn't immediately pick it up and rebuild everything. However that is something that you are probably still working on?

@azchohfi filed this as #161. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants