Error SetValue: Can not convert Large to type 'System.Double' when using style with OnIdiom

JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭

If I define a style like this:

    <Style x:Key="NamedSizeLargeOnIdiom" TargetType="Label">
        <Setter Property="FontSize">
            <Setter.Value>
                <OnIdiom x:TypeArguments="NamedSize" Tablet="Large" Phone="Medium" />
            </Setter.Value>
        </Setter>
    </Style>

Then I get the following error in my application output:

SetValue: Can not convert Large to type 'System.Double'

If I use OnIdiom with a numeric size, or a named size without OnIdiom, it's fine. So the first two styles below are fine, but the last one produces the error:

<Application.Resources>
    <ResourceDictionary>
    <Style x:Key="NamedSizeMediumNoOnIdiom" TargetType="Label">
        <Setter Property="FontSize" Value="Medium" />
    </Style>

    <Style x:Key="NumericSizeOnIdiom" TargetType="Label">
        <Setter Property="FontSize">
            <Setter.Value>
                <OnIdiom x:TypeArguments="x:Double" Tablet="60" Phone="50" />
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="NamedSizeLargeOnIdiom" TargetType="Label">
        <Setter Property="FontSize">
            <Setter.Value>
                <OnIdiom x:TypeArguments="NamedSize" Tablet="Large" Phone="Medium" />
            </Setter.Value>
        </Setter>
    </Style>            
    </ResourceDictionary>
</Application.Resources>

Is this a known bug?

Version information:

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.3.3 (build 5)
Installation UUID: 650b4c91-c7f5-4ee5-ad70-6f178f314906
Runtime:
Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit)
GTK+ 2.24.23 (Raleigh theme)

Package version: 504010007

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: Not installed
SDK: Not installed
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.1
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.1.3.0 (Visual Studio Enterprise)
Android SDK: /Users/jameslavery/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
7.1 (API level 25)
8.0 (API level 26)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 26.0.0
SDK Build Tools Version: 26.0.2

Java SDK: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Version: 1.3.2
Hash: 461f09a
Branch: 1.3-release
Build date: Tue, 03 Oct 2017 18:26:57 GMT
Client compatibility: 1

=== Apple Developer Tools ===

Xcode 8.0 (11246)

=== Xamarin.iOS ===

Version: 11.6.1.3 (Visual Studio Enterprise)
Hash: f70a1348
Branch: xcode9.2
Build date: 2017-12-18 14:47:16-0500

=== Xamarin.Mac ===

Version: 4.0.0.215 (Visual Studio Enterprise)

=== Build Information ===

Release ID: 703030005
Git revision: b1c2982e201e71ef758866c9ade05f253a8c6f47
Build date: 2017-12-21 11:04:40-05
Xamarin addins: f397ddfbacfb39e60c9cc8d9e410f73faf8c2cbc
Build lane: monodevelop-lion-d15-5

=== Operating System ===

Mac OS X 10.11.6
Darwin 15.6.0 Darwin Kernel Version 15.6.0
Thu Jun 23 18:25:34 PDT 2016
root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

LiveXAML 1.3.31
Redth's Addins 1.0.9
Internet of Things (IoT) development (Preview) 7.1

Best Answer

Answers

  • JamesLaveryJamesLavery GBBeta, University ✭✭✭✭✭
    Thanks although I'd classify this as a Xamarin Forms bug. We shouldn't have to create our own markup extensions.
Sign In or Register to comment.