Coder Social home page Coder Social logo

Comments (3)

Aspro1 avatar Aspro1 commented on July 17, 2024

I have just had the same problem. The solution is to make a class inheriting from the “TabItem” class with a parameterless constructor.

using NControl.Controls;

namespace MyControls
{
    public class TabPage : TabItem
    {
        public TabPage() : base(string.Empty, null)
        {
        }
    }
}

I also have a “TabControl” class inheriting from the original “TabStripControl” in my namespace.

using NControl.Controls;

namespace MyControls
{
    public class TabControl : TabStripControl
    {
    }
}

Then I can make for example such a piece of XAML:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:myControls="clr-namespace:MyControls;assembly=MyControls"
             x:Class="Test_CustomControls.TestPage_TabControl">
  <ScrollView>
    <StackLayout>
      <Label Text="Top label" />
      <myControls:TabControl HeightRequest="200" TabIndicatorColor="Blue" TabBackColor="Gray">
        <myControls:TabControl.Children>
          <myControls:TabPage Title="Tab 1">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Red">
                <Label Text="Tab 1: Label 1" />
                <Label Text="Tab 1: Label 2" />
                <Label Text="Tab 1: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
          <myControls:TabPage Title="Tab 2">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Green">
                <Label Text="Tab 2: Label 1" />
                <Label Text="Tab 2: Label 2" />
                <Label Text="Tab 2: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
          <myControls:TabPage Title="Tab 3">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Blue">
                <Label Text="Tab 3: Label 1" />
                <Label Text="Tab 3: Label 2" />
                <Label Text="Tab 3: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
        </myControls:TabControl.Children>        
      </myControls:TabControl>
      <Label Text="Middle label" />
      <myControls:TabControl HeightRequest="200" TabIndicatorColor="Blue" TabBackColor="Gray">
        <myControls:TabControl.Children>
          <myControls:TabPage Title="Tab 1">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Maroon">
                <Label Text="Tab 1: Label 1" />
                <Label Text="Tab 1: Label 2" />
                <Label Text="Tab 1: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
          <myControls:TabPage Title="Tab 2">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Teal">
                <Label Text="Tab 2: Label 1" />
                <Label Text="Tab 2: Label 2" />
                <Label Text="Tab 2: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
          <myControls:TabPage Title="Tab 3">
            <myControls:TabPage.View>
              <StackLayout BackgroundColor="Aqua">
                <Label Text="Tab 3: Label 1" />
                <Label Text="Tab 3: Label 2" />
                <Label Text="Tab 3: Label 3" />
              </StackLayout>
            </myControls:TabPage.View>
          </myControls:TabPage>
        </myControls:TabControl.Children>        
      </myControls:TabControl>
      <Label Text="Bottom label" />
    </StackLayout>
  </ScrollView>
</ContentPage>

from ncontrol.controls.

chrfalch avatar chrfalch commented on July 17, 2024

Please feel free to submit a pull request from the original code - with a
tabitem containing a parameterless constructor. I'm a bit overworked on
other projects at the moment... :-)

On Thu, Nov 19, 2015 at 1:16 PM, Aspro1 [email protected] wrote:

I have just had the same problem. The solution is to make a class
inheriting from the “TabItem” class with a parameterless constructor.

using NControl.Controls;

namespace MyControls
{
public class TabPage : TabItem
{
public TabPage() : base(string.Empty, null)
{
}
}
}

I also have a “TabControl” class inheriting from the original
“TabStripControl” in my namespace.

using NControl.Controls;

namespace MyControls
{
public class TabControl : TabStripControl
{
}
}

Then I can make for example such a piece of XAML:





<myControls:TabControl HeightRequest="200" TabIndicatorColor="Blue" TabBackColor="Gray">
myControls:TabControl.Children
<myControls:TabPage Title="Tab 1">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
<myControls:TabPage Title="Tab 2">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
<myControls:TabPage Title="Tab 3">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
/myControls:TabControl.Children
/myControls:TabControl

<myControls:TabControl HeightRequest="200" TabIndicatorColor="Blue" TabBackColor="Gray">
myControls:TabControl.Children
<myControls:TabPage Title="Tab 1">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
<myControls:TabPage Title="Tab 2">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
<myControls:TabPage Title="Tab 3">
myControls:TabPage.View





/myControls:TabPage.View
/myControls:TabPage
/myControls:TabControl.Children
/myControls:TabControl




Reply to this email directly or view it on GitHub
#6 (comment)
.

from ncontrol.controls.

johandep avatar johandep commented on July 17, 2024

Great, thanks Aspro1!

from ncontrol.controls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.