Referencing a static string from an external library in Xaml.

bcafazzobcafazzo USMember ✭✭

When I recently updated from Xamarin.Forms.2.3.0.107 to Xamarin.Forms.2.3.3.175 some of my Xaml views have begun failing with an error Object reference not set to an instance of an object. After some finessing I've found that the failing Xaml views are all referencing an external library I wrote containing a list of constant strings. The simplest reproduction I have is as follows:

<?xml version="1.0" encoding="UTF-8"?> <ContentView xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:constants="clr-namespace:FontAwesome.Constants;assembly=FontAwesome.Constants" x:Class="WexMobile.Core.Controls.OmniMenu.Test"> <ContentView.Content> <Label Text="{x:Static constants:FA.STEP_FORWARD}" /> </ContentView.Content> </ContentView>

If I change the Text property to something else, including a static that exists in the same project, it compiles just fine. FA.STEP_FORWARD is a simple string containing the glyphcode of the FontAwesome "Step Forward" icon.

My assumption is that the FontAwesome constants library cannot be found by the Xaml compiler so it just dies when trying to create it.

Any thoughts on how to go about getting around this?

Sign In or Register to comment.