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)

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


Attachments

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

Notice (2018-05-21): bugzilla.xamarin.com will be switching to read-only mode on Thursday, 2018-05-25 22:00 UTC.

Please join us on Visual Studio Developer Community and GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs and copy them to the new locations as needed for follow-up. The See Also field on each Bugzilla bug will be updated with a link to its new location when applicable.

After Bugzilla is read-only, if you have new information to add for a bug that does not yet have a matching issue on Developer Community or GitHub, you can create a follow-up issue in the new location. Copy and paste the title and description from this bug, and then add your new details. You can get a pre-formatted version of the title and description here:

In special cases you might also want the comments:

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.

Note You need to log in before you can comment on or make changes to this bug.