Bug 45891 - XamlParseException Cannot use OnIdiom with an inherited type.
Summary: XamlParseException Cannot use OnIdiom with an inherited type.
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.3.3
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Stephane Delcroix
URL:
Depends on:
Blocks:
 
Reported: 2016-10-25 15:39 UTC by Brad Chase
Modified: 2017-02-02 14:33 UTC (History)
2 users (show)

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

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 FIXED

Description Brad Chase 2016-10-25 15:39:37 UTC
{Xamarin.Forms.Xaml.XamlParseException: Position 63:10. Cannot assign property "Columns": type mismatch between "Xamarin.Forms.OnIdiom`1[Library.Controls.ColumnList]" 
  and "System.Collections.Generic.IEnumerable`1[Library.Controls.DataGridColumn]"

I tried to set an idiom to a property that was of type IEnumerable<DataGridColumn>.  Unfortunately if you create a class of type ColumnList : IEnumerable<DataGridColumn>, then the idiom fails with the above XamlParseException.

To set the property, I use:

<controls:PickerModal.Columns>
        <OnIdiom x:TypeArguments="controls:ColumnList">
            <OnIdiom.Phone>
                <controls:ColumnList>


The Property:

        public static readonly BindableProperty ColumnsProperty = BindableProperty.Create<DataGrid, IEnumerable<DataGridColumn>>(w => w.Columns, null, BindingMode.Default, null, OnColumnsPropertyChanged, null, null, null);
        public IEnumerable<DataGridColumn> Columns
        {
            get { return (IEnumerable<DataGridColumn>)GetValue(ColumnsProperty); }
            set { SetValue(ColumnsProperty, value); }
        }


The inherited class:

    public class ColumnList : List<DataGridColumn>
    {

    }
Comment 1 Stephane Delcroix 2017-01-25 12:47:36 UTC
fixed in https://github.com/xamarin/Xamarin.Forms/pull/715
Comment 2 Stephane Delcroix 2017-02-02 14:33:17 UTC
this will be fixed in 2.3.5-pre1