Page 1 of 1

[SOLVED] Error in Window.OnMouseOver

Posted: Mon Aug 07, 2017 6:36 am
by kmatt
In the simulator, when I move the mouse across elements created in an htmlpresenter, I get errors that come from the cshtml5 libraries.
This is the xaml:

<native:HtmlPresenter Name="mapToolbar" VerticalAlignment="Top" Visibility="Visible" HorizontalAlignment="Stretch"/>

And this is the code behind (it occurs well after the UserControl is loaded):
mapToolbar = mapScreen.GetMapToolbar();
mapToolbar.Html = "<nav id=\"toolbar\" display=\"inline\">" +
"<label for=\"ShowFootPrintsButton\" style=\"font-size:14px;font-weight:bold;\">Show Footprints</label>" +
"<input id=\"ShowFootPrintsButton\" name=\"ShowFootPrintsButton\" type=\"checkbox\"/ onclick=\"btnShowFootPrints_Click\">" +

// Set up menu callback from javascript
var _referenceToTheJavaScriptToolbarObject = mapToolbar.DomElement;
@"$0.btnShowFootPrints_Click = $1;",
implemented as:
private void OnToolbarShowFootPrintsCallback(object obj)
throw new NotImplementedException();

Error in Window.OnMouseOver(...): The "INTERNAL_idsToUIElements" dictionary does not contain the following key:ShowFootPrintsButton

I must be creating the elements incorrectly but there are no errors displayed on creation. Clicking on the item gives the same error. If I add a () after $1 I do not get the error and the C# method is called - as the items is created, not when it is clicked.

Re: Error in Window.OnMouseOver

Posted: Tue Aug 08, 2017 9:10 am
by kmatt
Fixed it. In xaml the set for the onclick in javascript needed a "()". Also had to name the onclick javascript event method different than the id for the item. The event also need to belong to window instead of to the javascript menu object.