This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
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

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