├── .github └── workflows │ ├── code_cov.yaml │ └── release-nuget.yml ├── .gitignore ├── .vscode └── launch.json ├── LICENSE ├── README.md ├── nuget.png ├── samples ├── SegmentedControlSamples │ ├── App.xaml │ ├── App.xaml.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── MauiProgram.cs │ ├── Platforms │ │ ├── Android │ │ │ ├── AndroidManifest.xml │ │ │ ├── MainActivity.cs │ │ │ ├── MainApplication.cs │ │ │ └── Resources │ │ │ │ └── values │ │ │ │ └── colors.xml │ │ ├── MacCatalyst │ │ │ ├── AppDelegate.cs │ │ │ ├── Info.plist │ │ │ └── Program.cs │ │ ├── Tizen │ │ │ ├── Main.cs │ │ │ └── tizen-manifest.xml │ │ ├── Windows │ │ │ ├── App.xaml │ │ │ ├── App.xaml.cs │ │ │ ├── Package.appxmanifest │ │ │ └── app.manifest │ │ └── iOS │ │ │ ├── AppDelegate.cs │ │ │ ├── Info.plist │ │ │ └── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Resources │ │ ├── AppIcon │ │ │ ├── appicon.svg │ │ │ └── appiconfg.svg │ │ ├── Fonts │ │ │ ├── OpenSans-Regular.ttf │ │ │ └── OpenSans-Semibold.ttf │ │ ├── Images │ │ │ └── dotnet_bot.svg │ │ ├── Raw │ │ │ └── AboutAssets.txt │ │ ├── Splash │ │ │ └── splash.svg │ │ └── Styles │ │ │ ├── Colors.xaml │ │ │ └── Styles.xaml │ ├── SegControlTest1.xaml │ ├── SegControlTest1.xaml.cs │ ├── SegControlTest2.xaml │ ├── SegControlTest2.xaml.cs │ ├── SegmentedControlSamples.csproj │ ├── SegmentedControlSamples.sln │ └── Test2ViewModel.cs └── Test.SegmentedControl │ ├── App.xaml │ ├── App.xaml.cs │ ├── AppShell.xaml │ ├── AppShell.xaml.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── MainViewModel.cs │ ├── MauiProgram.cs │ ├── Platforms │ ├── Android │ │ ├── AndroidManifest.xml │ │ ├── MainActivity.cs │ │ ├── MainApplication.cs │ │ └── Resources │ │ │ └── values │ │ │ └── colors.xml │ ├── MacCatalyst │ │ ├── AppDelegate.cs │ │ ├── Entitlements.plist │ │ ├── Info.plist │ │ └── Program.cs │ ├── Tizen │ │ ├── Main.cs │ │ └── tizen-manifest.xml │ ├── Windows │ │ ├── App.xaml │ │ ├── App.xaml.cs │ │ ├── Package.appxmanifest │ │ └── app.manifest │ └── iOS │ │ ├── AppDelegate.cs │ │ ├── Info.plist │ │ └── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Resources │ ├── AppIcon │ │ ├── appicon.svg │ │ └── appiconfg.svg │ ├── Fonts │ │ ├── OpenSans-Regular.ttf │ │ └── OpenSans-Semibold.ttf │ ├── Images │ │ └── dotnet_bot.png │ ├── Raw │ │ └── AboutAssets.txt │ ├── Splash │ │ └── splash.svg │ └── Styles │ │ ├── Colors.xaml │ │ └── Styles.xaml │ ├── Test.SegmentedControl.csproj │ └── Test.SegmentedControl.sln └── src └── Plugin.Maui.SegmentedControl ├── .vscode └── settings.json ├── Control ├── ElementChildrenChanging.cs ├── GroupToggleBehavior.cs ├── ISegmentedControl.cs ├── SegmentTappedEventArgs.cs ├── SegmentedControl.cs ├── SegmentedControlOption.cs └── ValueChangedEventArgs.cs ├── Extensions └── AppHostBuilderExtensions.cs ├── Handlers └── SegmentedControlHandler.standart.cs ├── Platforms ├── Android │ ├── Resources │ │ ├── AboutResources.txt │ │ ├── color │ │ │ └── segmented_control_text.xml │ │ ├── drawable │ │ │ ├── segmented_control_background.xml │ │ │ ├── segmented_control_first_background.xml │ │ │ └── segmented_control_last_background.xml │ │ ├── layout │ │ │ ├── RadioButton.axml │ │ │ └── RadioGroup.axml │ │ └── values │ │ │ └── colors.xml │ └── SegmentedControlHandler.cs ├── MacCatalyst │ └── SegmentedControlHandler.cs └── iOS │ └── SegmentedControlHandler.cs ├── Plugin.Maui.SegmentedControl.csproj ├── Plugin.Maui.SegmentedControl.nuspec └── Plugin.Maui.SegmentedControl.sln /.github/workflows/code_cov.yaml: -------------------------------------------------------------------------------- 1 | - name: Upload coverage reports to Codecov 2 | uses: codecov/codecov-action@v3 3 | env: 4 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 5 | -------------------------------------------------------------------------------- /.github/workflows/release-nuget.yml: -------------------------------------------------------------------------------- 1 | name: Create a release on NuGet 2 | 3 | on: 4 | workflow_dispatch: 5 | push: 6 | tags: 7 | - "v[0-9]+.[0-9]+.[0-9]+" 8 | jobs: 9 | release-nuget: 10 | 11 | runs-on: windows-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: Verify commit exists in origin/main 16 | run: | 17 | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 18 | git branch --remote --contains | grep origin/main 19 | - name: Set VERSION variable from tag 20 | run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV 21 | - name: Install .NET MAUI 22 | run: dotnet workload install maui 23 | - name: Add msbuild to PATH 24 | uses: microsoft/setup-msbuild@v1.1 25 | - name: Get version information from tag 26 | id: get_version 27 | uses: battila7/get-version-action@v2 28 | - name: Pack 29 | run: msbuild -t:pack -r src/Plugin.Maui.SegmentedControl/Plugin.Maui.SegmentedControl.sln -property:Configuration=Release 30 | - name: Push 31 | run: dotnet nuget push src\Plugin.Maui.SegmentedControl\bin\Release\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.NUGET_API_KEY }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET MAUI", 9 | "type": "maui", 10 | "request": "launch", 11 | "preLaunchTask": "maui: Build" 12 | }, 13 | { 14 | "name": ".NET Meteor Debugger", 15 | "type": "dotnet-meteor.debugger", 16 | "request": "launch", 17 | "preLaunchTask": "dotnet-meteor: Build" 18 | } 19 | ] 20 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Yuriy Holembyovskyy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Plugin.Maui.SegmentedControl 2 | .NET MAUI Port of Alex Rainman XF Segmented control https://github.com/alexrainman/SegmentedControl 3 | ### Setup 4 | * Available on NuGet: https://www.nuget.org/packages/Plugin.Maui.SegmentedControl/ 5 | 6 | 7 | **Platform Support** 8 | 9 | |Platform|Supported|Version|Renderer| 10 | | ------------------- | :-----------: | :-----------: | :------------------: | 11 | |iOS Unified|Yes|iOS 8.1+|UISegmentedControl| 12 | |Android|Yes|API 18+|RadioGroup| 13 | |Mac OS |Yes| 11.0+|UISegmentedControl| 14 | 15 | ### Screenshot 16 | ![Screenshot](https://github.com/yurkinh/Plugin.Maui.SegmentedControl/assets/17849938/d184c9a2-093c-4bc9-8546-35dfe0c5de87) 17 | 18 | #### Usage 19 | 20 | In your MaiuProgram file call: 21 | 22 | ``` 23 | var builder = MauiApp.CreateBuilder(); 24 | builder 25 | .UseMauiApp() 26 | .UseSegmentedControl(); 27 | ``` 28 | 29 | #### XAML 30 | 31 | ```xml 32 | xmlns:controls="clr-namespace:Plugin.Maui.SegmentedControl;assembly=Plugin.Maui.SegmentedControl" 33 | ``` 34 | 35 | ```xml 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | ``` 47 | 48 | #### Event handler 49 | 50 | ``` 51 | public void Handle_ValueChanged(object o, int e) 52 | { 53 | SegContent.Children.Clear(); 54 | 55 | switch (e) 56 | { 57 | case 0: 58 | SegContent.Children.Add(new Label() { Text="Tab 1 selected" }); 59 | break; 60 | case 1: 61 | SegContent.Children.Add(new Label() { Text = "Tab 2 selected" }); 62 | break; 63 | case 2: 64 | SegContent.Children.Add(new Label() { Text = "Tab 3 selected" }); 65 | break; 66 | case 3: 67 | SegContent.Children.Add(new Label() { Text = "Tab 4 selected" }); 68 | break; 69 | } 70 | } 71 | ``` 72 | 73 | **Bindable Properties** 74 | 75 | ```TintColor```: Fill color for the control (Color, default #007AFF) 76 | 77 | ```SelectedTextColor```: Selected segment text color (Color, default #FFFFFF) 78 | 79 | ```SelectedSegment```: Selected segment index (int, default 0). 80 | 81 | **Event Handlers** 82 | 83 | ```ValueChanged```: Called when a segment is selected. 84 | -------------------------------------------------------------------------------- /nuget.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurkinh/Plugin.Maui.SegmentedControl/bf0d5ebaa65fd1bf8e9714d92d4e3bbb1664733a/nuget.png -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SegmentedControlSamples; 2 | 3 | public partial class App : Application 4 | { 5 | public App() => InitializeComponent(); 6 | 7 | protected override Window CreateWindow(IActivationState activationState) => new(new MainPage()); 8 | } 9 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace SegmentedControlSamples; 2 | 3 | public partial class MainPage : ContentPage 4 | { 5 | 6 | 7 | public MainPage() 8 | { 9 | InitializeComponent(); 10 | 11 | Title = "Segmented Control"; 12 | } 13 | 14 | void Handle_ValueChanged(object sender, Plugin.Maui.SegmentedControl.ValueChangedEventArgs e) 15 | { 16 | switch (e.NewValue) 17 | { 18 | case 0: 19 | SegContent.Content = new SegControlTest1(); 20 | (SegContent as IView).InvalidateMeasure(); 21 | break; 22 | case 1: 23 | SegContent.Content = new SegControlTest2(); 24 | (SegContent as IView).InvalidateMeasure(); 25 | break; 26 | case 2: 27 | SegContent.Content = new Label() { Text = "TEST 3 tab selected" }; 28 | break; 29 | case 3: 30 | SegContent.Content = new Label() { Text = "TEST 4 tab selected" }; 31 | break; 32 | } 33 | } 34 | 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | using CommunityToolkit.Maui; 2 | using Microsoft.Extensions.Logging; 3 | using Plugin.Maui.SegmentedControl; 4 | 5 | namespace SegmentedControlSamples; 6 | 7 | public static class MauiProgram 8 | { 9 | public static MauiApp CreateMauiApp() 10 | { 11 | var builder = MauiApp.CreateBuilder(); 12 | builder 13 | .UseMauiApp() 14 | .UseMauiCommunityToolkit() 15 | .UseSegmentedControl() 16 | .ConfigureFonts(fonts => 17 | { 18 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 19 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 20 | }); 21 | 22 | #if DEBUG 23 | builder.Logging.AddDebug(); 24 | #endif 25 | 26 | return builder.Build(); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace SegmentedControlSamples; 6 | 7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] 8 | public class MainActivity : MauiAppCompatActivity 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace SegmentedControlSamples; 5 | 6 | [Application] 7 | public class MainApplication : MauiApplication 8 | { 9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership) 10 | : base(handle, ownership) 11 | { 12 | } 13 | 14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace SegmentedControlSamples; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | UIDeviceFamily 6 | 7 | 1 8 | 2 9 | 10 | UIRequiredDeviceCapabilities 11 | 12 | arm64 13 | 14 | UISupportedInterfaceOrientations 15 | 16 | UIInterfaceOrientationPortrait 17 | UIInterfaceOrientationLandscapeLeft 18 | UIInterfaceOrientationLandscapeRight 19 | 20 | UISupportedInterfaceOrientations~ipad 21 | 22 | UIInterfaceOrientationPortrait 23 | UIInterfaceOrientationPortraitUpsideDown 24 | UIInterfaceOrientationLandscapeLeft 25 | UIInterfaceOrientationLandscapeRight 26 | 27 | XSAppIconAssets 28 | Assets.xcassets/appicon.appiconset 29 | 30 | 31 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace SegmentedControlSamples; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.Maui; 3 | using Microsoft.Maui.Hosting; 4 | 5 | namespace SegmentedControlSamples; 6 | 7 | class Program : MauiApplication 8 | { 9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 10 | 11 | static void Main(string[] args) 12 | { 13 | var app = new Program(); 14 | app.Run(args); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Tizen/tizen-manifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | maui-appicon-placeholder 7 | 8 | 9 | 10 | 11 | http://tizen.org/privilege/internet 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Windows/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.UI.Xaml; 2 | 3 | // To learn more about WinUI, the WinUI project structure, 4 | // and more about our project templates, see: http://aka.ms/winui-project-info. 5 | 6 | namespace SegmentedControlSamples.WinUI; 7 | 8 | /// 9 | /// Provides application-specific behavior to supplement the default Application class. 10 | /// 11 | public partial class App : MauiWinUIApplication 12 | { 13 | /// 14 | /// Initializes the singleton application object. This is the first line of authored code 15 | /// executed, and as such is the logical equivalent of main() or WinMain(). 16 | /// 17 | public App() 18 | { 19 | this.InitializeComponent(); 20 | } 21 | 22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Windows/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | $placeholder$ 15 | User Name 16 | $placeholder$.png 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace SegmentedControlSamples; 4 | 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | 11 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | LSRequiresIPhoneOS 6 | 7 | UIDeviceFamily 8 | 9 | 1 10 | 2 11 | 12 | UIRequiredDeviceCapabilities 13 | 14 | arm64 15 | 16 | UISupportedInterfaceOrientations 17 | 18 | UIInterfaceOrientationPortrait 19 | UIInterfaceOrientationLandscapeLeft 20 | UIInterfaceOrientationLandscapeRight 21 | 22 | UISupportedInterfaceOrientations~ipad 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationPortraitUpsideDown 26 | UIInterfaceOrientationLandscapeLeft 27 | UIInterfaceOrientationLandscapeRight 28 | 29 | XSAppIconAssets 30 | Assets.xcassets/appicon.appiconset 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | using UIKit; 3 | 4 | namespace SegmentedControlSamples; 5 | 6 | public class Program 7 | { 8 | // This is the main entry point of the application. 9 | static void Main(string[] args) 10 | { 11 | // if you want to use a different Application Delegate class from "AppDelegate" 12 | // you can specify it here. 13 | UIApplication.Main(args, null, typeof(AppDelegate)); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/AppIcon/appiconfg.svg: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurkinh/Plugin.Maui.SegmentedControl/bf0d5ebaa65fd1bf8e9714d92d4e3bbb1664733a/samples/SegmentedControlSamples/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yurkinh/Plugin.Maui.SegmentedControl/bf0d5ebaa65fd1bf8e9714d92d4e3bbb1664733a/samples/SegmentedControlSamples/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Images/dotnet_bot.svg: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Raw/AboutAssets.txt: -------------------------------------------------------------------------------- 1 | Any raw assets you want to be deployed with your application can be placed in 2 | this directory (and child directories). Deployment of the asset to your application 3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`. 4 | 5 | 6 | 7 | These files will be deployed with you package and will be accessible using Essentials: 8 | 9 | async Task LoadMauiAsset() 10 | { 11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt"); 12 | using var reader = new StreamReader(stream); 13 | 14 | var contents = reader.ReadToEnd(); 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Splash/splash.svg: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Styles/Colors.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | #512BD4 8 | #DFD8F7 9 | #2B0B98 10 | White 11 | Black 12 | #E1E1E1 13 | #C8C8C8 14 | #ACACAC 15 | #919191 16 | #6E6E6E 17 | #404040 18 | #212121 19 | #141414 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | #F7B548 35 | #FFD590 36 | #FFE5B9 37 | #28C2D1 38 | #7BDDEF 39 | #C3F2F4 40 | #3E8EED 41 | #72ACF1 42 | #A7CBF6 43 | 44 | 45 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Resources/Styles/Styles.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 10 | 11 | 15 | 16 | 21 | 22 | 25 | 26 | 49 | 50 | 67 | 68 | 88 | 89 | 110 | 111 | 132 | 133 | 138 | 139 | 159 | 160 | 178 | 179 | 183 | 184 | 206 | 207 | 222 | 223 | 243 | 244 | 247 | 248 | 271 | 272 | 292 | 293 | 299 | 300 | 319 | 320 | 323 | 324 | 352 | 353 | 373 | 374 | 378 | 379 | 391 | 392 | 397 | 398 | 404 | 405 | 406 | 407 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegControlTest1.xaml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 61 | 62 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegControlTest1.xaml.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Maui.SegmentedControl; 2 | 3 | namespace SegmentedControlSamples; 4 | 5 | public partial class SegControlTest1 : ContentView 6 | { 7 | public SegControlTest1() 8 | { 9 | InitializeComponent(); 10 | SegmentedControl.Children = _list1; 11 | 12 | } 13 | 14 | private readonly SegmentedControlOption[] _list1 = { 15 | new SegmentedControlOption{Text="Test0A"}, 16 | new SegmentedControlOption{Text="Test1A"}, 17 | new SegmentedControlOption{Text="Test2A"} 18 | }; 19 | 20 | internal SegmentedControlOption[] List2 = { 21 | new SegmentedControlOption{Text="Item1B"}, 22 | new SegmentedControlOption{Text="Item2B"}, 23 | new SegmentedControlOption{Text="Item3B"}, 24 | new SegmentedControlOption{Text="Item4B"}, 25 | new SegmentedControlOption{Text="Item5B"} 26 | }; 27 | bool _isList2 = false; 28 | 29 | 30 | private void ChangeChildren_Clicked(object sender, EventArgs e) 31 | { 32 | if(_isList2) 33 | { 34 | SegmentedControl.Children = _list1; 35 | } 36 | else 37 | { 38 | SegmentedControl.Children = List2; 39 | } 40 | _isList2 = !_isList2; 41 | } 42 | 43 | 44 | private void Button_OnClicked(object sender, EventArgs e) 45 | { 46 | SegmentWithStack.Children.Remove(SegmentedControl); 47 | } 48 | 49 | private void ButtonTintColor_OnClicked(object sender, EventArgs e) 50 | { 51 | if (SegmentedControl.SelectedTextColor != Colors.Aqua) 52 | { 53 | SegmentedControl.TintColor = Colors.Aqua; 54 | } 55 | else 56 | { 57 | SegmentedControl.TintColor = Colors.BlueViolet; 58 | } 59 | } 60 | 61 | private void ButtonSelectedTextColor_OnClicked(object sender, EventArgs e) 62 | { 63 | if(SegmentedControl.SelectedTextColor != Colors.Red) 64 | { 65 | SegmentedControl.SelectedTextColor = Colors.Red; 66 | } 67 | else 68 | { 69 | SegmentedControl.SelectedTextColor = Colors.Green; 70 | } 71 | 72 | } 73 | 74 | private void ButtonBorderColor_OnClicked(object sender, EventArgs e) 75 | { 76 | //SegmentedControl.BorderColor = Color.Crimson; 77 | } 78 | 79 | private void ButtonBorderWidth_OnClicked(object sender, EventArgs e) 80 | { 81 | //SegmentedControl.BorderWidth = (SegmentedControl.BorderWidth + 1) % 3; 82 | } 83 | 84 | private void ButtonBackgroundColor_OnClicked(object sender, EventArgs e) 85 | { 86 | SegmentedControl.BackgroundColor = Colors.HotPink; 87 | } 88 | 89 | private void Disable_OnClicked(object sender, EventArgs e) 90 | { 91 | SegmentedControl.IsEnabled = false; 92 | } 93 | 94 | private void Enable_OnClicked(object sender, EventArgs e) 95 | { 96 | SegmentedControl.IsEnabled = true; 97 | } 98 | 99 | private bool _isDisabledColorChanged; 100 | private Color _defaultDisabledColor; 101 | private void ChangeDisabledTintColor_OnClicked(object sender, EventArgs e) 102 | { 103 | if (_isDisabledColorChanged) 104 | { 105 | SegmentedControl.DisabledTintColor = _defaultDisabledColor; 106 | } 107 | else 108 | { 109 | _defaultDisabledColor = SegmentedControl.DisabledTintColor; 110 | SegmentedControl.DisabledTintColor = Colors.Red; 111 | } 112 | _isDisabledColorChanged = !_isDisabledColorChanged; 113 | } 114 | 115 | private void ChangeSelectedSegment(object sender, EventArgs e) 116 | { 117 | if(SegmentedControl.SelectedSegment < 0) 118 | { 119 | SegmentedControl.SelectedSegment = 0; 120 | return; 121 | } 122 | 123 | if(SegmentedControl.SelectedSegment < SegmentedControl.Children.Count) 124 | { 125 | SegmentedControl.SelectedSegment += 1; 126 | return; 127 | } 128 | 129 | SegmentedControl.SelectedSegment = 0; 130 | 131 | } 132 | 133 | private void ChangeFirstText(object sender, EventArgs e) 134 | { 135 | const string boundText = "Item 1B"; 136 | SegmentedControl.Children[0].Text = 137 | SegmentedControl.Children[0].Text == boundText 138 | ? "Item1" 139 | : boundText; 140 | } 141 | 142 | public void DisableFirstSegment_OnClicked(object sender, EventArgs e) 143 | { 144 | SegmentedControl.Children[0].IsEnabled = false; 145 | } 146 | 147 | public void EnableFirstSegment_OnClicked(object sender, EventArgs e) 148 | { 149 | SegmentedControl.Children[0].IsEnabled = true; 150 | } 151 | 152 | //public void OnElementChildrenChanging(object sender, ElementChildrenChanging e) 153 | //{ 154 | // if (e.OldValues != null && e.OldValues.Count > 0) 155 | // { 156 | // e.OldValues[0].RemoveBinding(SegmentedControlOption.TextProperty); 157 | // } 158 | // if (e.NewValues != null && e.NewValues.Count > 0) 159 | // { 160 | // e.NewValues[0].SetBinding(SegmentedControlOption.TextProperty, nameof(_viewModel.ChangeText)); 161 | // } 162 | //} 163 | 164 | public void ChangeTextSize_OnClicked(object sender, EventArgs e) 165 | { 166 | //SegmentedControl.FontSize = SegmentedControl.FontSize < 20 ? 20 : 12; 167 | } 168 | 169 | public void ChangeFontFamily_OnClicked(object sender, EventArgs e) 170 | { 171 | //switch (Device.RuntimePlatform) 172 | //{ 173 | // case Device.Android: 174 | // SegmentedControl.FontFamily = SegmentedControl.FontFamily == "monospace" ? "serif" : "monospace"; 175 | // break; 176 | 177 | // case Device.iOS: 178 | // case Device.macOS: 179 | // SegmentedControl.FontFamily = SegmentedControl.FontFamily == "Baskerville" ? "HelveticaNeue" : "Baskerville"; 180 | // break; 181 | 182 | // case Device.UWP: 183 | // SegmentedControl.FontFamily = SegmentedControl.FontFamily == "Courier New" ? "Microsoft Sans Serif" : "Courier New"; 184 | // break; 185 | 186 | //} 187 | } 188 | 189 | 190 | private bool _isTextColorChanged; 191 | private Color _defaultTextColor; 192 | 193 | private void Button_TextColor(object sender, EventArgs e) 194 | { 195 | if (!_isTextColorChanged) 196 | { 197 | _defaultTextColor = SegmentedControl.TextColor; 198 | SegmentedControl.TextColor = Colors.Red; 199 | _isTextColorChanged = true; 200 | } 201 | else 202 | { 203 | _isTextColorChanged = false; 204 | SegmentedControl.TextColor = _defaultTextColor; 205 | } 206 | } 207 | 208 | 209 | } -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegControlTest2.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 73 | 74 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegControlTest2.xaml.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Maui.SegmentedControl; 2 | 3 | namespace SegmentedControlSamples; 4 | 5 | public partial class SegControlTest2 : ContentView 6 | { 7 | Test2ViewModel _viewModel; 8 | 9 | public SegControlTest2() 10 | { 11 | InitializeComponent(); 12 | 13 | SegmentedControl.BindingContext = _viewModel = new Test2ViewModel(); 14 | } 15 | 16 | private void SegmentedControl_ValueChanged(object sender, Plugin.Maui.SegmentedControl.ValueChangedEventArgs e) 17 | { 18 | segmentIndexLabel.Text = e.NewValue.ToString(); 19 | } 20 | 21 | PlayerStatus _playerStatus = PlayerStatus.Stopped; 22 | private void SegmentedControl_SegmentTapped(object sender, SegmentTappedEventArgs e) 23 | { 24 | if (e.Index == 1) 25 | { 26 | if (_playerStatus == PlayerStatus.Playing) 27 | { 28 | SegmentedControl.Children[1].Text = "Play"; 29 | _playerStatus = PlayerStatus.Stopped; 30 | } 31 | else 32 | { 33 | SegmentedControl.Children[1].Text = "Stop"; 34 | _playerStatus = PlayerStatus.Playing; 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegmentedControlSamples.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net9.0-android;net9.0-ios;net9.0-maccatalyst 5 | $(TargetFrameworks);net9.0-windows10.0.19041.0 6 | 7 | 8 | Exe 9 | SegmentedControlSamples 10 | true 11 | true 12 | enable 13 | 14 | 15 | SegmentedControlSamples 16 | 17 | 18 | com.companyname.segmentedcontrolsamples 19 | 05bd9285-b60e-4ece-b89c-d9cdf0278e53 20 | 21 | 22 | 1.0 23 | 1 24 | 25 | 15.0 26 | 15.0 27 | 21.0 28 | 31 | 32 | 33 | 34 | false 35 | 36 | 37 | false 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | MSBuild:Compile 71 | 72 | 73 | MSBuild:Compile 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/SegmentedControlSamples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 25.0.1706.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SegmentedControlSamples", "SegmentedControlSamples.csproj", "{D9F807D2-1EC2-4B01-A359-D4358DBACDA0}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Plugin.Maui.SegmentedControl", "..\..\src\Plugin.Maui.SegmentedControl\Plugin.Maui.SegmentedControl.csproj", "{DC6F9F63-6ED9-4EB1-AE24-E5008C7F9721}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D9F807D2-1EC2-4B01-A359-D4358DBACDA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {D9F807D2-1EC2-4B01-A359-D4358DBACDA0}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {D9F807D2-1EC2-4B01-A359-D4358DBACDA0}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {D9F807D2-1EC2-4B01-A359-D4358DBACDA0}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {DC6F9F63-6ED9-4EB1-AE24-E5008C7F9721}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {DC6F9F63-6ED9-4EB1-AE24-E5008C7F9721}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {DC6F9F63-6ED9-4EB1-AE24-E5008C7F9721}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {DC6F9F63-6ED9-4EB1-AE24-E5008C7F9721}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {36835921-6C7A-4E43-AB39-A1A8D13598C3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /samples/SegmentedControlSamples/Test2ViewModel.cs: -------------------------------------------------------------------------------- 1 | using Plugin.Maui.SegmentedControl; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Input; 9 | 10 | namespace SegmentedControlSamples 11 | { 12 | public enum PlayerStatus 13 | { 14 | Stopped = 0, 15 | Playing = 1, 16 | } 17 | 18 | public class Test2ViewModel : INotifyPropertyChanged 19 | { 20 | public List _playList = new List 21 | { 22 | "Song One", 23 | "Song Two", 24 | "Song Three", 25 | "Song Four", 26 | }; 27 | 28 | Timer _timer; 29 | int _curSongSecond; 30 | public ICommand SegmentTappedCommand { get; } 31 | 32 | 33 | 34 | public Test2ViewModel() 35 | { 36 | _timer = new Timer(OnTimer); 37 | 38 | SegmentTappedCommand = new Command((a) => 39 | { 40 | if (a.Index == 1) 41 | { 42 | if (PlayerStatus == PlayerStatus.Playing) 43 | { 44 | PlayerStatus = PlayerStatus.Stopped; 45 | } 46 | else 47 | { 48 | PlayerStatus = PlayerStatus.Playing; 49 | } 50 | } 51 | }); 52 | PlayerStatus = PlayerStatus.Stopped; 53 | PlayButtonText = "Play"; 54 | ForwardButtonEnabled = true; 55 | ForwardButtonText = "Forward"; 56 | SelectedSegment = -1; 57 | } 58 | 59 | private void OnTimer(object s) 60 | { 61 | 62 | } 63 | 64 | 65 | private PlayerStatus _playerStatus; 66 | private PlayerStatus PlayerStatus 67 | { 68 | get { return _playerStatus; } 69 | set 70 | { 71 | _playerStatus = value; 72 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(PlayerStatusText))); 73 | PlayButtonText = _playerStatus == PlayerStatus.Playing ? "STOP" : "Play"; 74 | } 75 | } 76 | 77 | public string PlayerStatusText 78 | { 79 | get { return this.PlayerStatus.ToString(); } 80 | } 81 | 82 | private string _playButtonText; 83 | public string PlayButtonText 84 | { 85 | get => _playButtonText; 86 | set { _playButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(PlayButtonText))); } 87 | } 88 | 89 | private bool _backButtonEnabled = true; 90 | public bool BackButtonEnabled 91 | { 92 | get => _backButtonEnabled; 93 | set { _backButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(BackButtonEnabled))); } 94 | } 95 | 96 | private bool _forwardButtonEnabled = true; 97 | public bool ForwardButtonEnabled 98 | { 99 | get => _forwardButtonEnabled; 100 | set { _forwardButtonEnabled = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonEnabled))); } 101 | } 102 | 103 | private string _forwardButtonText; 104 | public string ForwardButtonText 105 | { 106 | get => _forwardButtonText; 107 | set { _forwardButtonText = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(ForwardButtonText))); } 108 | } 109 | 110 | 111 | private int _selectedSegment; 112 | public int SelectedSegment 113 | { 114 | get => _selectedSegment; 115 | set 116 | { 117 | _selectedSegment = value; 118 | OnPropertyChanged(new PropertyChangedEventArgs(nameof(SelectedSegment))); 119 | } 120 | } 121 | private IList _segmentItemsSource; 122 | public IList SegmentItemsSource 123 | { 124 | get => _segmentItemsSource; 125 | set { _segmentItemsSource = value; OnPropertyChanged(new PropertyChangedEventArgs(nameof(SegmentItemsSource))); } 126 | } 127 | 128 | 129 | public event PropertyChangedEventHandler PropertyChanged; 130 | protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) 131 | { 132 | PropertyChanged?.Invoke(this, e); 133 | } 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /samples/Test.SegmentedControl/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /samples/Test.SegmentedControl/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Test.SegmentedControl; 2 | 3 | public partial class App : Application 4 | { 5 | public App() => InitializeComponent(); 6 | 7 | protected override Window CreateWindow(IActivationState activationState) => new(new MainPage()); 8 | } 9 | -------------------------------------------------------------------------------- /samples/Test.SegmentedControl/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /samples/Test.SegmentedControl/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Test.SegmentedControl; 2 | 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /samples/Test.SegmentedControl/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 8 | 9 | 10 | 16 | 17 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 41 | 42 | 44 | 45 | 46 | 50 | 52 | 54 | 55 | 66 | 68 |