Git Product home page Git Product logo

how-to-load-different-content-page-as-tab-items-content-in-.net-maui-tabview's Introduction

This article illustrates to load different content page as Tab items content in .NET MAUI TabView, follow the below steps,

Step 1: Create a new sample in .NET MAUI and initialize TabView within the page with BindingContext.

Step 2: Create multiple .NET MAUI content pages in the sample and create new ViewModel class for assigning created content pages in the observable collection.

Step 3: Give proper name for the observable collection and add the content pages to that collection.

XAML

    <ContentPage.BindingContext>
        <local:ViewModel/>
    </ContentPage.BindingContext>
    <tabView:SfTabView  Items="{Binding Items}"/>
    

C#

public class ViewModel : INotifyPropertyChanged
{
    private TabItemCollection items;
    public event PropertyChangedEventHandler PropertyChanged;
    public TabItemCollection Items
    {
        get { return items; }
        set
        {
            items = value;
            OnPropertyChanged("Items");
        }
    }

    protected virtual void OnPropertyChanged(string propertyName)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    public ViewModel()
    {
        SetItems();
    }

    internal void SetItems()
    {
        Items = new TabItemCollection();
        TabViewPage1 page1 = new TabViewPage1();
        TabViewPage2 page2 = new TabViewPage2();
        TabViewPage3 page3 = new TabViewPage3();
        TabViewPage4 page4 = new TabViewPage4();
        Items.Add(new SfTabItem { Content = page1.Content, Header = "Page1" });
        Items.Add(new SfTabItem { Content = page2.Content, Header = "Page2" });
        Items.Add(new SfTabItem { Content = page3.Content, Header = "Page3" });
        Items.Add(new SfTabItem { Content = page4.Content, Header = "Page4" });
    }
}

Output

TabViewPages.png

how-to-load-different-content-page-as-tab-items-content-in-.net-maui-tabview's People

Contributors

edberg-vasan avatar naveenkumar-sanjeevirayan avatar sarubala20 avatar sivaranjithn avatar syncfusionbuild avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

how-to-load-different-content-page-as-tab-items-content-in-.net-maui-tabview's Issues

Pages Open but are not displayed correctly

Used the exampe as described but when a page is loaded the behaviour is strange. First page is with a Treeview, shows background color but nothing more, on second page changes the background color and only displays first row of the view and code behind does not run. Flat page like in the example loads ok.

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.