{"id":23061639,"url":"https://github.com/syncfusionexamples/xamarin-forms-sfsegment","last_synced_at":"2025-04-03T07:18:53.122Z","repository":{"id":98096402,"uuid":"362005789","full_name":"SyncfusionExamples/xamarin-forms-sfsegment","owner":"SyncfusionExamples","description":"This repository contains a sample on How to get started with the Syncfusion Xamarin.Forms SegmentedControl (SfSegmentedControl)?","archived":false,"fork":false,"pushed_at":"2024-03-22T10:44:05.000Z","size":557,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-08T20:48:18.357Z","etag":null,"topics":["segment","segmented-control","segmentedcontrol","xamarin","xamarin-forms"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SyncfusionExamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-27T06:33:07.000Z","updated_at":"2024-03-28T09:42:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"f55589b1-0ecf-4584-964b-7cd43e865a74","html_url":"https://github.com/SyncfusionExamples/xamarin-forms-sfsegment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fxamarin-forms-sfsegment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fxamarin-forms-sfsegment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fxamarin-forms-sfsegment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Fxamarin-forms-sfsegment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyncfusionExamples","download_url":"https://codeload.github.com/SyncfusionExamples/xamarin-forms-sfsegment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246952280,"owners_count":20859813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["segment","segmented-control","segmentedcontrol","xamarin","xamarin-forms"],"created_at":"2024-12-16T03:18:00.164Z","updated_at":"2025-04-03T07:18:53.100Z","avatar_url":"https://github.com/SyncfusionExamples.png","language":"C#","readme":"# Xamarin Segmented Control (SfSegmentedControl) \n\nThe Segmented Control for Xamarin.Forms provides a simple way to choose from a linear set of two or more segments, each of which functions as a mutually exclusive button.\n\nFor know more details about Segmented: https://www.syncfusion.com/xamarin-ui-controls/xamarin-segmented-control\n\nSegmented user guide documentation: https://help.syncfusion.com/xamarin/segmented-control/getting-started\n\n## Getting Started with Xamarin Segmented Control (SfSegmentedControl)\n\nThis section provides an overview for working with the segmented control for Xamarin.Forms. Walk through the entire process of creating a real-world application with the SfSegmentedControl.\n\n### Adding SfSegmentedControl reference\nYou can add SfSegmentedControl reference using one of the following methods:\n\n#### Method 1: Adding SfSegmentedControl reference from nuget.org\n\nSyncfusion Xamarin components are available in nuget.org. To add SfSegmentedControl to your project, open the NuGet package manager in Visual Studio, search for Syncfusion.Xamarin.Buttons, and then install it.\n\n#### Method 2: Adding SfSegmentedControl reference from toolbox\n\nSyncfusion also provides Xamarin Toolbox. Using this toolbox, you can drag the SfSegmentedControl control to the XAML page. It will automatically install the required NuGet packages and add the namespace to the page. To install Syncfusion Xamarin Toolbox, refer to Toolbox.\n\n#### Method 3: Adding SfSegmentedControl assemblies manually from the installed location\n\nIf you prefer to manually reference the assemblies instead referencing from NuGet, add the following assemblies in respective projects.\n\nLocation: {Installed location}/{version}/Xamarin/lib\n\n## Creating a project\nCreate a new BlankApp (Xamarin.Forms.Portable) application in Visual Studio for Xamarin.Forms.\n\n### Adding SfSegmentedControl in Xamarin.Forms\nAdd the required assembly references to the PCL and renderer projects as discussed in the Assembly deployment  section.\n\nImport the control namespace as shown in the following code.\n\n**[XAML]**\n\n```\nxmlns:buttons=\"clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms\"\n```\nSet the control to content in ContentPage.\n\n**[XAML]**\n```\n\u003cContentPage.Content\u003e\n    \u003cbuttons:SfSegmentedControl  /\u003e\n\u003c/ContentPage.Content\u003e\n```\n### Adding supportive views to the application\nFor the completeness of the ticket booking application, few framework controls are added to the application to get the data from the user.\n\nViewModel class for the Entry, which we have used in our View.\n\n**[C#]**\n```\n    using Syncfusion.XForms.Buttons;\n    using System;\n    using System.Collections.ObjectModel;\n    using System.ComponentModel;\n    using System.Runtime.CompilerServices;\n    using Xamarin.Forms;\n    \n    namespace SegmentGettingStarted\n    {\n        class ViewModel : INotifyPropertyChanged\n        {\n            private string fromText=\"\";\n            public string FromText\n            {\n                get { return fromText; }\n                set { fromText = value; NotifyPropertyChanged(\"FromText\"); }\n            }\n            private string toText = \"\";\n            public string ToText\n            {\n                get { return toText; }\n                set { toText = value; NotifyPropertyChanged(\"ToText\"); }\n            }\n            public ViewModel()\n            {\n            }\n            public event PropertyChangedEventHandler PropertyChanged;\n    \n            private void NotifyPropertyChanged([CallerMemberName] String propertyName = \"\")\n            {\n                if (PropertyChanged != null)\n                {\n                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));\n                }\n            }\n        }\n    }\n```\nView can be created by the following code snippet.\n\n**[XAML]**\n\n```\n    \u003cContentPage.BindingContext\u003e\n        \u003clocal:ViewModel/\u003e\n    \u003c/ContentPage.BindingContext\u003e\n    \u003cStackLayout \n        HorizontalOptions=\"Center\"\n        VerticalOptions=\"Center\"\n        Padding=\"20,0,20,0\"\u003e\n        \u003cLabel\n            Text=\"Bus Ticket Booking\"\n            FontSize=\"Large\"\n            FontAttributes=\"Bold\"\n            HeightRequest=\"50\"\n            HorizontalOptions=\"Center\"\n            VerticalOptions=\"Center\"/\u003e\n        \u003cEntry\n            Placeholder=\"From\"\n            Text=\"{Binding FromText,Mode=TwoWay}\"\n            HeightRequest=\"50\"\n            Margin=\"0,10,0,10\"/\u003e\n        \u003cEntry\n            Placeholder=\"To\"\n            Text=\"{Binding ToText}\"\n            HeightRequest=\"50\"\n            Margin=\"0,10,0,10\"/\u003e\n        \u003cbuttons:SfSegmentedControl \n            x:Name=\"Class\" \n            HeightRequest=\"80\"\n            VisibleSegmentsCount=\"2\"\n            Color=\"White\"\n            SelectionTextColor=\"#007CEE\"\n            FontColor=\"#929292\"\n            BorderColor=\"#929292\"\n            SelectedIndex=\"1\"\n            ItemsSource=\"{Binding ItemCollection,Mode=TwoWay}\"\n            BackgroundColor=\"Transparent\"\u003e\n            \u003cbuttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n                \u003cbuttons:SelectionIndicatorSettings \n                    Color=\"White\"\u003e\n                \u003c/buttons:SelectionIndicatorSettings\u003e\n            \u003c/buttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n        \u003c/buttons:SfSegmentedControl\u003e\n        \u003cbuttons:SfSegmentedControl\n            SelectionTextColor=\"White\"\n            HeightRequest=\"80\"\n            VisibleSegmentsCount=\"6\"\n            Color=\"Transparent\" \n            BorderColor=\"#929292\"\n            SelectedIndex=\"1\"\n            ItemsSource=\"{Binding}\"\n            FontColor=\"#929292\"\n            BackgroundColor=\"Transparent\" \u003e\n            \u003csegmentCollection:List x:TypeArguments=\"x:String\"\u003e\n                \u003cx:String\u003e1\u003c/x:String\u003e\n                \u003cx:String\u003e2\u003c/x:String\u003e\n                \u003cx:String\u003e3\u003c/x:String\u003e\n                \u003cx:String\u003e4\u003c/x:String\u003e\n                \u003cx:String\u003e5\u003c/x:String\u003e\n                \u003cx:String\u003e6\u003c/x:String\u003e\n            \u003c/segmentCollection:List\u003e\n            \u003cbuttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n                \u003cbuttons:SelectionIndicatorSettings \n                    Color=\"#007CEE\"\n                    Position=\"Fill\"\u003e\n                \u003c/buttons:SelectionIndicatorSettings\u003e\n            \u003c/buttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n        \u003c/buttons:SfSegmentedControl\u003e\n        \u003cbuttons:SfSegmentedControl\n            BorderColor=\"Transparent\" \n            HeightRequest=\"80\"\n            HorizontalOptions=\"Center\"\n            x:Name=\"ViewContainer\"\n            VisibleSegmentsCount=\"2\"\n            Color=\"Transparent\"\n            ItemsSource=\"{Binding ViewCollection}\"\n            SegmentPadding=\"30\"\u003e\n            \u003cbuttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n                \u003cbuttons:SelectionIndicatorSettings\n                    Color=\"Transparent\"\u003e\n                \u003c/buttons:SelectionIndicatorSettings\u003e\n            \u003c/buttons:SfSegmentedControl.SelectionIndicatorSettings\u003e\n        \u003c/buttons:SfSegmentedControl\u003e\n    \u003c/StackLayout\u003e\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fxamarin-forms-sfsegment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyncfusionexamples%2Fxamarin-forms-sfsegment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Fxamarin-forms-sfsegment/lists"}