I am needing to use this.setHtmlAttribute. I have installed Uno.WinUi.Runtime.Webassembly as it said at this link: Embedding Existing JavaScript Components Into Uno-WASM, but when I try to setHtmlAttribute, I get an error saying The type 'UIElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'Uno.UI, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'. First of all, I can't find a version 255.255.255.255, but when I install the latest version, 4.9.20, it says Cannot build with both Uno.WinUI and Uno.UI nuget packages referenced., and even after deleting any Uno.Ui package references, that error persists until I create a new Uno project and move any files to that. Here is the code that was throwing an error:
using Microsoft.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uno.UI.Runtime.WebAssembly; // when I add [HtmlElement("div")] after installing Uno.Winui.Runtime.WebAssembly it automatically adds this. It doesn't throw any errors on its own, only when I add setHtmlAttribute
using Windows.System.Preview;
namespace Project.XamlElements
{
[HtmlElement("div")]
public sealed partial class MapControl: FrameworkElement
{
public MapControl()
{
#if __WASM__
//has error with or without conditional
this.SetHtmlAttribute("id", "4");
#endif
}
}
}
I think the problem might be that I need to make the package reference conditional, but I can't find anything on the docs for what the targetName for wasm is.
//<ItemGroup Condition = "'$(TargetFramework)' == 'wasm? or webassembly?' ">
//<PackageReference Include="Uno.WinUI.Runtime.WebAssembly" />
//</ItemGroup>