Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syncfusionexamples/xamarin.forms-segmentedcontrol-with-event-to-command-behavior
This repository contains sample on Event to Command Behavior in the Syncfusion Xamarin.Forms SegmentedControl (SfSegmentedControl) control?
https://github.com/syncfusionexamples/xamarin.forms-segmentedcontrol-with-event-to-command-behavior
event-to-command-behavior segementcontrol segmented-control xamarin xamarin-forms
Last synced: about 1 month ago
JSON representation
This repository contains sample on Event to Command Behavior in the Syncfusion Xamarin.Forms SegmentedControl (SfSegmentedControl) control?
- Host: GitHub
- URL: https://github.com/syncfusionexamples/xamarin.forms-segmentedcontrol-with-event-to-command-behavior
- Owner: SyncfusionExamples
- Created: 2021-08-05T12:16:27.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-22T10:56:24.000Z (10 months ago)
- Last Synced: 2024-04-14T12:07:22.736Z (10 months ago)
- Topics: event-to-command-behavior, segementcontrol, segmented-control, xamarin, xamarin-forms
- Language: C#
- Homepage:
- Size: 592 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Creating a project
Create a new BlankApp (Xamarin.Forms.Portable) application in Visual Studio for Xamarin.Forms.## Adding SfSegmentedControl in Xamarin.Forms
Add the required assembly references to the PCL and renderer projects as discussed in the Assembly deployment section.Import the control namespace as shown in the following code.
**[XAML]**
```
xmlns:buttons="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
```
Set the control to content in ContentPage.**[XAML]**
```
```
## Dealing with selection changed in Xamarin Segmented ControlThe selection changed event occurs when there is a change from one segment item to another in the segmented control. It can be handled by two ways.
### User interface
When users navigate from one item to another, selection is changed, so that the SelectedIndex value is updated to the new index of the item. The segmented control provides the SelectionChanged event, which is triggered when the selection is changed with the SelectionChangedEventArgs.Index - Gets the current index value of the selected item.
**[XAML]**
```
```
### Selected Index through programmatically.
Users can set the default value programmatically for the selection to be placed. The selection is updated based on the index value given for the SelectedIndex.**[XAML]**
``````
### Event to command
The SegmentedControl event can be converted into commands using Behaviors. To achieve this, create a command in the ViewModel class and use Behaviors to associate it to the SegmentedControl event.
**[XAML]**
```
```
## How to run this application?To run this application, you need to first clone the xamarin.forms-segmentedcontrol-with-event-to-command-behavior repository and then open it in Visual Studio 2022. Now, simply build and run your project to view the output.
## Troubleshooting ##
### Path too long exception
If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.## License
Syncfusion has no liability for any damage or consequence that may arise by using or viewing the samples. The samples are for demonstrative purposes, and if you choose to use or access the samples, you agree to not hold Syncfusion liable, in any form, for any damage that is related to use, for accessing, or viewing the samples. By accessing, viewing, or seeing the samples, you acknowledge and agree Syncfusion’s samples will not allow you seek injunctive relief in any form for any claim related to the sample. If you do not agree to this, do not view, access, utilize, or otherwise do anything with Syncfusion’s samples.