Bug 60452 - OnIdiom bug
Summary: OnIdiom bug
Status: RESOLVED DUPLICATE of bug 58922
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.5.0
Hardware: PC Windows
: Highest blocker
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2017-10-31 10:59 UTC by harel123
Modified: 2018-03-05 15:56 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Repro example project (849.70 KB, application/x-rar)
2017-11-20 18:04 UTC, harel123
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 58922

Description harel123 2017-10-31 10:59:24 UTC
I was using Xamarin.Forms 2.3.4.270 until today when I decided to upgrade to the latest stable release of Xamarin.Forms (2.4.0.38779). After the upgrade I didn't change anything in my code, however, at some places where I used OnIdiom in my code I am now getting errors of "No property, bindable property, or event found for '{Property I used OnIdiom for goes here}', or mismatching type between value and property." when I try to build.
For example: 

<Image Source="{Binding ImageSource, Converter={StaticResource BinaryToImageConverter}}" Aspect="AspectFit">
   <Image.HeightRequest>
     <OnIdiom x:TypeArguments="x:Double" Phone="150" Tablet="300" />
   </Image.HeightRequest>
</Image>

Gives me the following error: "No property, bindable property, or event found forr 'HeightRequest', or mismatching type between value and property".
Again, I would like to point out that before when I was using Xamarin.Forms 2.3.4.270 this same line (along with the others I'm now getting errors from) worked fine. 

I found a bug that seems similar to this on Bugzilla: https://bugzilla.xamarin.com/show_bug.cgi?id=58922 however I could not find an answer for my issue there (I did try the solutions suggested there but the same error persisted).
Comment 1 harel123 2017-10-31 11:59:56 UTC
UPDATE: I am using the [XamlCompilation(XamlCompilationOptions.Compile)] attribute in the code-behind and noticed that when I get rid of it, I don't get these errors and the pages from which these errors occured open with no error.
Comment 2 Paul DiPietro [MSFT] 2017-10-31 14:03:41 UTC
Can you upload a reproduction? It may also be worth focusing on following up on the referred to ticket instead of opening an entirely new one as the issue looks to be from the same general cause.
Comment 3 harel123 2017-11-13 11:30:13 UTC
To reproduce this, you can create a blank Xamarin.Forms project targetting Xamarin.Forms 2.4+ (I tested it for 2.4.0.38779 and 2.4.0.74863 as well as Xamarin.Forms 2.5.0.75255-pre3), and, for example, in the XAML of the MainPage, create a label and set it's HeightRequest property to an instance of OnIdiom, for instance:

<Label Text="Welcome to Xamarin.Forms">
    <Label.HeightRequest>
        <OnIdiom x:TypeArguments="x:Double" Phone="100" Tablet="200" />
    </Label.HeightRequest>
</Label>

That causes the error I'm getting as well. For this particular example, the error is: "No property, bindable property, or event found for 'HeightRequest', or mismatching type between value and property.".

I would also like to mention that I have an OnIdiom instance set for the Margin property of a frame (where the x:TypeArguments is set to "Thickness") which doesn't seem to raise the error. As far as I can see, the error only raises for instances of OnIdiom in XAML set for either the HeightRequest or WidthRequest properties of any control, where the x:TypeArguments is set to x:Double.
Comment 4 harel123 2017-11-13 11:49:50 UTC
UPDATE 2: Seems like defining an instance of OnIdiom in XAML as a Resource within the ResourceDictionary, defining a key to it and then setting the HeightRequest and WidthRequest properties of a control to that resource works. However, setting HeightRequest or WidthRequest directly to an instance of OnIdiom as shown in my previous comments does not seem to work... 
So you could say this is a temporary workaround, which I prefer not to use considering I have different values for Phone and Tablet for each OnIdiom instance.
Comment 5 Paul DiPietro [MSFT] 2017-11-17 18:30:07 UTC
I believe this is ultimately related to the original #58922 issue and that the behavior was simply not supposed to work as stated there. If your workaround does what you need it to then I suggest staying with it.

*** This bug has been marked as a duplicate of bug 58922 ***
Comment 6 harel123 2017-11-20 18:04:12 UTC
I was asked on this bug report: https://bugzilla.xamarin.com/show_bug.cgi?id=58922
To reopen my ticket and provide a repro project. I wrote here: https://bugzilla.xamarin.com/show_bug.cgi?id=60452#c3 how you can reproduce this issue and I would like to mention I am getting the same results also after updating to Xamarin.Forms 2.5.0.91635. I will provide an example project as an attachment as well, which basically follows the instructions on how to reproduce this issue I provided in https://bugzilla.xamarin.com/show_bug.cgi?id=60452#c3.
Comment 7 harel123 2017-11-20 18:04:54 UTC
Created attachment 25767 [details]
Repro example project
Comment 8 Leo 2017-12-05 18:52:54 UTC
I'm experiencing the same issue. OnIdiom/OnPlatform failed when XAMLC is enabled in a .NET Standard 2 project using XF 2.5.0.91635. Please let me know if you need anything else to reproduce the issue. The error is reproducible following harel123 indications.
Comment 9 Mikalai Daronin 2018-01-31 19:00:24 UTC
Same problem. Simple "x:Double" work, "OnIdiom" doesn't. With x:TypeArguments="x:Double" removed it doesn't even compile. Very frustrating.

> <StackLayout.Resources>
>     <ResourceDictionary>
>         <x:Double x:Key="dividerHeight">20</x:Double>
>         <OnIdiom x:Key="columnWidth" x:TypeArguments="x:Double">
>             <OnIdiom.Phone>50</OnIdiom.Phone>
>             <OnIdiom.Tablet>80</OnIdiom.Tablet>
>         </OnIdiom>
>     </ResourceDictionary>
> </StackLayout.Resources>
Comment 10 Paul DiPietro [MSFT] 2018-03-05 15:56:49 UTC
Resolving as a duplicate of the aforementioned issue. Please use the other issue or more specifically file new issues on GitHub as we use that for tracking.

*** This bug has been marked as a duplicate of bug 58922 ***