chaosifier / TabView

TabView control for Xamarin.Forms.
MIT License
124 stars 32 forks source link

TabView in XAML #15

Closed twopienka closed 5 years ago

twopienka commented 6 years ago

Hi,

I tried to add TabView to my solution. Everything is fine as long as I add the TabView from my code as shown in the sample.

But when I add it like this to my XAML: `

meninomiel commented 6 years ago

The same for me. Any solution for that?

twopienka commented 6 years ago

I did not find a solution for this. We now use Telerik controls - anyway I would still be interested in a solution for this.

eiadxp commented 5 years ago

I know that I'm a little late but just today I've used this library and I got the same problem.... Nuget package version now is 1.0.3 which is older than the current code on GitHub..... The nuget code does not include any parameterless constructors for TabView and for TabItem classes.

To solve this problem you can build the current code from GitHub and use it in your project (They already added parameterless constructors for TabView and for TabItem classes.).

Or you can do what I did in my project.... Create to classes that inherits from TabView and TabItem, and add parameterless constructors like this:

    [ContentProperty(nameof(ItemSource))]
    public class TabView : Xam.Plugin.TabView.TabViewControl
    {
        public TabView() : base(new List<Xam.Plugin.TabView.TabItem>(), -1)
        {

        }
    }
    [ContentProperty(nameof(Content))]
    public class TabItem : Xam.Plugin.TabView.TabItem
    {
        public TabItem() : base("", new ContentView())
        {

        }
    }

Now you can use it normally in your XAML files:

    <ctr:TabView>
        <ctr:TabItem HeaderText="Commands"/>
        <ctr:TabItem HeaderText="Tools"/>
    </ctr:TabView>

Please tell me if it is working.....

AmorimRob commented 5 years ago

Thanks @eiadxp it works for me !

eiadxp commented 5 years ago

Happy it worked for you @AmorimRob ….

meninomiel commented 5 years ago

I know that I'm a little late but just today I've used this library and I got the same problem.... Nuget package version now is 1.0.3 which is older than the current code on GitHub..... The nuget code does not include any parameterless constructors for TabView and for TabItem classes.

To solve this problem you can build the current code from GitHub and use it in your project (They already added parameterless constructors for TabView and for TabItem classes.).

Or you can do what I did in my project.... Create to classes that inherits from TabView and TabItem, and add parameterless constructors like this:

    [ContentProperty(nameof(ItemSource))]
    public class TabView : Xam.Plugin.TabView.TabViewControl
    {
        public TabView() : base(new List<Xam.Plugin.TabView.TabItem>(), -1)
        {

        }
    }
    [ContentProperty(nameof(Content))]
    public class TabItem : Xam.Plugin.TabView.TabItem
    {
        public TabItem() : base("", new ContentView())
        {

        }
    }

Now you can use it normally in your XAML files:

    <ctr:TabView>
        <ctr:TabItem HeaderText="Commands"/>
        <ctr:TabItem HeaderText="Tools"/>
    </ctr:TabView>

Please tell me if it is working.....

I ended up writing the UI in c#. I will try your solution later. Thanks for answer.

twopienka commented 5 years ago

Thank you @eiadxp - your solution to this works just fine.