question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[UWP] TouchEffect not working when app compiled with UseDotNetNativeToolchain=true

See original GitHub issue

When publishing an app to the windows store, it’ll be recompiled with UseDotNetNativeToolchain set to true by Microsoft.

We can test this by building locally with <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain> in the Release build configuration, and so far my experience is that code that uses toucheffect doesn’t work (ie I can click stuff and nothing happens - no errors, no ui changes).

I’ve set the TouchEffectPreserver.Preserve(); line in the UWP project’s app.xaml.cs file but no luck so far.

Has anyone else dealt with this issue?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
MitchBomcanhaocommented, Aug 20, 2019

as a final comment, this is the bare minimum I’ve kept

Xamarin.Forms.Forms.Init(e, new[] { typeof(TouchEffect.UWP.PlatformTouchEff).Assembly });

no system.reflection needed.

on a project where I’m using rgplugins.popup, which also needs to be added to this list of assemblies, I’ve joined them up like so:

Rg.Plugins.Popup.Popup.Init();

Xamarin.Forms.Forms.Init(
    e,
    Rg.Plugins.Popup.Popup.GetExtraAssemblies().Concat(
        new[] { typeof(TouchEffect.UWP.PlatformTouchEff).Assembly })
    );
1reaction
MitchBomcanhaocommented, Aug 20, 2019

I’ve found something that makes it work - just not sure it is a good workaround. Had to add using System.Reflection; and then the following initialization for Xamarin forms in app.xaml.cs:

// For .NET Native compilation, you have to tell Xamarin.Forms which assemblies it should scan for custom controls and renderers 
var otherAssemblies = new[] 
{
    typeof(PlatformTouchEff).GetTypeInfo().Assembly
};
Xamarin.Forms.Forms.Init(e, otherAssemblies);

this was following an example from https://www.mrgestures.com/#FAQs. This might be problematic as it might conflict with the fixes for other packages which do similar things, but at least there’s some progress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin.CommunityToolKit TouchEffect.Command not ...
I can't succeed to make the xct:TouchEffect.Command working on UWP while: ... The binding for the command of the button is working on...
Read more >
Touch Effect | Xamarin.Forms | Xamarin Community Toolkit
TouchEffect allows any view (not only buttons) to handle “Normal”, “Pressed”, “Hovered” states and change its appearance according to the ...
Read more >
How to use Maui TouchEffect? - Microsoft Q&A
In Xamarin Forms we could use TouchEffect to determine if there was a touch and what type. The code we used is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found