├── .gitignore ├── LICENSE ├── MPowerKit.TabView.sln ├── MPowerKit.TabView ├── Alignment.cs ├── InverseBooleanConverter.cs ├── ItemsPresenter.cs ├── MPowerKit.TabView.csproj ├── ScrollOrientationToStackOrientationConverter.cs ├── TabVIew.cs ├── TabViewHeaderItem.cs ├── TabViewItem.cs ├── TabViewStyle.xaml └── TabViewStyle.xaml.cs ├── Sample ├── App.xaml ├── App.xaml.cs ├── AppShell.xaml ├── AppShell.xaml.cs ├── MainPage.xaml ├── MainPage.xaml.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 └── Sample.csproj ├── icon.png └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | # globs 2 | Makefile.in 3 | *.userprefs 4 | *.usertasks 5 | config.make 6 | config.status 7 | aclocal.m4 8 | install-sh 9 | autom4te.cache/ 10 | *.tar.gz 11 | tarballs/ 12 | test-results/ 13 | 14 | # Mac bundle stuff 15 | *.dmg 16 | *.app 17 | 18 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 19 | # General 20 | .DS_Store 21 | .AppleDouble 22 | .LSOverride 23 | 24 | # Icon must end with two \r 25 | Icon 26 | 27 | 28 | # Thumbnails 29 | ._* 30 | 31 | # Files that might appear in the root of a volume 32 | .DocumentRevisions-V100 33 | .fseventsd 34 | .Spotlight-V100 35 | .TemporaryItems 36 | .Trashes 37 | .VolumeIcon.icns 38 | .com.apple.timemachine.donotpresent 39 | 40 | # Directories potentially created on remote AFP share 41 | .AppleDB 42 | .AppleDesktop 43 | Network Trash Folder 44 | Temporary Items 45 | .apdisk 46 | 47 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 48 | # Windows thumbnail cache files 49 | Thumbs.db 50 | ehthumbs.db 51 | ehthumbs_vista.db 52 | 53 | # Dump file 54 | *.stackdump 55 | 56 | # Folder config file 57 | [Dd]esktop.ini 58 | 59 | # Recycle Bin used on file shares 60 | $RECYCLE.BIN/ 61 | 62 | # Windows Installer files 63 | *.cab 64 | *.msi 65 | *.msix 66 | *.msm 67 | *.msp 68 | 69 | # Windows shortcuts 70 | *.lnk 71 | 72 | # content below from: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 73 | ## Ignore Visual Studio temporary files, build results, and 74 | ## files generated by popular Visual Studio add-ons. 75 | ## 76 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 77 | 78 | # User-specific files 79 | *.suo 80 | *.user 81 | *.userosscache 82 | *.sln.docstates 83 | 84 | # User-specific files (MonoDevelop/Xamarin Studio) 85 | *.userprefs 86 | 87 | # Build results 88 | [Dd]ebug/ 89 | [Dd]ebugPublic/ 90 | [Rr]elease/ 91 | [Rr]eleases/ 92 | x64/ 93 | x86/ 94 | bld/ 95 | [Bb]in/ 96 | [Oo]bj/ 97 | [Ll]og/ 98 | 99 | # Visual Studio 2015/2017 cache/options directory 100 | .vs/ 101 | # Uncomment if you have tasks that create the project's static files in wwwroot 102 | #wwwroot/ 103 | 104 | # Visual Studio 2017 auto generated files 105 | Generated\ Files/ 106 | 107 | # MSTest test Results 108 | [Tt]est[Rr]esult*/ 109 | [Bb]uild[Ll]og.* 110 | 111 | # NUNIT 112 | *.VisualState.xml 113 | TestResult.xml 114 | 115 | # Build Results of an ATL Project 116 | [Dd]ebugPS/ 117 | [Rr]eleasePS/ 118 | dlldata.c 119 | 120 | # Benchmark Results 121 | BenchmarkDotNet.Artifacts/ 122 | 123 | # .NET Core 124 | project.lock.json 125 | project.fragment.lock.json 126 | artifacts/ 127 | 128 | # StyleCop 129 | StyleCopReport.xml 130 | 131 | # Files built by Visual Studio 132 | *_i.c 133 | *_p.c 134 | *_h.h 135 | *.ilk 136 | *.meta 137 | *.obj 138 | *.iobj 139 | *.pch 140 | *.pdb 141 | *.ipdb 142 | *.pgc 143 | *.pgd 144 | *.rsp 145 | *.sbr 146 | *.tlb 147 | *.tli 148 | *.tlh 149 | *.tmp 150 | *.tmp_proj 151 | *_wpftmp.csproj 152 | *.log 153 | *.vspscc 154 | *.vssscc 155 | .builds 156 | *.pidb 157 | *.svclog 158 | *.scc 159 | 160 | # Chutzpah Test files 161 | _Chutzpah* 162 | 163 | # Visual C++ cache files 164 | ipch/ 165 | *.aps 166 | *.ncb 167 | *.opendb 168 | *.opensdf 169 | *.sdf 170 | *.cachefile 171 | *.VC.db 172 | *.VC.VC.opendb 173 | 174 | # Visual Studio profiler 175 | *.psess 176 | *.vsp 177 | *.vspx 178 | *.sap 179 | 180 | # Visual Studio Trace Files 181 | *.e2e 182 | 183 | # TFS 2012 Local Workspace 184 | $tf/ 185 | 186 | # Guidance Automation Toolkit 187 | *.gpState 188 | 189 | # ReSharper is a .NET coding add-in 190 | _ReSharper*/ 191 | *.[Rr]e[Ss]harper 192 | *.DotSettings.user 193 | 194 | # JustCode is a .NET coding add-in 195 | .JustCode 196 | 197 | # TeamCity is a build add-in 198 | _TeamCity* 199 | 200 | # DotCover is a Code Coverage Tool 201 | *.dotCover 202 | 203 | # AxoCover is a Code Coverage Tool 204 | .axoCover/* 205 | !.axoCover/settings.json 206 | 207 | # Visual Studio code coverage results 208 | *.coverage 209 | *.coveragexml 210 | 211 | # NCrunch 212 | _NCrunch_* 213 | .*crunch*.local.xml 214 | nCrunchTemp_* 215 | 216 | # MightyMoose 217 | *.mm.* 218 | AutoTest.Net/ 219 | 220 | # Web workbench (sass) 221 | .sass-cache/ 222 | 223 | # Installshield output folder 224 | [Ee]xpress/ 225 | 226 | # DocProject is a documentation generator add-in 227 | DocProject/buildhelp/ 228 | DocProject/Help/*.HxT 229 | DocProject/Help/*.HxC 230 | DocProject/Help/*.hhc 231 | DocProject/Help/*.hhk 232 | DocProject/Help/*.hhp 233 | DocProject/Help/Html2 234 | DocProject/Help/html 235 | 236 | # Click-Once directory 237 | publish/ 238 | 239 | # Publish Web Output 240 | *.[Pp]ublish.xml 241 | *.azurePubxml 242 | # Note: Comment the next line if you want to checkin your web deploy settings, 243 | # but database connection strings (with potential passwords) will be unencrypted 244 | *.pubxml 245 | *.publishproj 246 | 247 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 248 | # checkin your Azure Web App publish settings, but sensitive information contained 249 | # in these scripts will be unencrypted 250 | PublishScripts/ 251 | 252 | # NuGet Packages 253 | *.nupkg 254 | # The packages folder can be ignored because of Package Restore 255 | **/[Pp]ackages/* 256 | # except build/, which is used as an MSBuild target. 257 | !**/[Pp]ackages/build/ 258 | # Uncomment if necessary however generally it will be regenerated when needed 259 | #!**/[Pp]ackages/repositories.config 260 | # NuGet v3's project.json files produces more ignorable files 261 | *.nuget.props 262 | *.nuget.targets 263 | 264 | # Microsoft Azure Build Output 265 | csx/ 266 | *.build.csdef 267 | 268 | # Microsoft Azure Emulator 269 | ecf/ 270 | rcf/ 271 | 272 | # Windows Store app package directories and files 273 | AppPackages/ 274 | BundleArtifacts/ 275 | Package.StoreAssociation.xml 276 | _pkginfo.txt 277 | *.appx 278 | 279 | # Visual Studio cache files 280 | # files ending in .cache can be ignored 281 | *.[Cc]ache 282 | # but keep track of directories ending in .cache 283 | !*.[Cc]ache/ 284 | 285 | # Others 286 | ClientBin/ 287 | ~$* 288 | *~ 289 | *.dbmdl 290 | *.dbproj.schemaview 291 | *.jfm 292 | *.pfx 293 | *.publishsettings 294 | orleans.codegen.cs 295 | 296 | # Including strong name files can present a security risk 297 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 298 | #*.snk 299 | 300 | # Since there are multiple workflows, uncomment next line to ignore bower_components 301 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 302 | #bower_components/ 303 | 304 | # RIA/Silverlight projects 305 | Generated_Code/ 306 | 307 | # Backup & report files from converting an old project file 308 | # to a newer Visual Studio version. Backup files are not needed, 309 | # because we have git ;-) 310 | _UpgradeReport_Files/ 311 | Backup*/ 312 | UpgradeLog*.XML 313 | UpgradeLog*.htm 314 | ServiceFabricBackup/ 315 | *.rptproj.bak 316 | 317 | # SQL Server files 318 | *.mdf 319 | *.ldf 320 | *.ndf 321 | 322 | # Business Intelligence projects 323 | *.rdl.data 324 | *.bim.layout 325 | *.bim_*.settings 326 | *.rptproj.rsuser 327 | 328 | # Microsoft Fakes 329 | FakesAssemblies/ 330 | 331 | # GhostDoc plugin setting file 332 | *.GhostDoc.xml 333 | 334 | # Node.js Tools for Visual Studio 335 | .ntvs_analysis.dat 336 | node_modules/ 337 | 338 | # Visual Studio 6 build log 339 | *.plg 340 | 341 | # Visual Studio 6 workspace options file 342 | *.opt 343 | 344 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 345 | *.vbw 346 | 347 | # Visual Studio LightSwitch build output 348 | **/*.HTMLClient/GeneratedArtifacts 349 | **/*.DesktopClient/GeneratedArtifacts 350 | **/*.DesktopClient/ModelManifest.xml 351 | **/*.Server/GeneratedArtifacts 352 | **/*.Server/ModelManifest.xml 353 | _Pvt_Extensions 354 | 355 | # Paket dependency manager 356 | .paket/paket.exe 357 | paket-files/ 358 | 359 | # FAKE - F# Make 360 | .fake/ 361 | 362 | # JetBrains Rider 363 | .idea/ 364 | *.sln.iml 365 | 366 | # CodeRush personal settings 367 | .cr/personal 368 | 369 | # Python Tools for Visual Studio (PTVS) 370 | __pycache__/ 371 | *.pyc 372 | 373 | # Cake - Uncomment if you are using it 374 | # tools/** 375 | # !tools/packages.config 376 | 377 | # Tabs Studio 378 | *.tss 379 | 380 | # Telerik's JustMock configuration file 381 | *.jmconfig 382 | 383 | # BizTalk build output 384 | *.btp.cs 385 | *.btm.cs 386 | *.odx.cs 387 | *.xsd.cs 388 | 389 | # OpenCover UI analysis results 390 | OpenCover/ 391 | 392 | # Azure Stream Analytics local run output 393 | ASALocalRun/ 394 | 395 | # MSBuild Binary and Structured Log 396 | *.binlog 397 | 398 | # NVidia Nsight GPU debugger configuration file 399 | *.nvuser 400 | 401 | # MFractors (Xamarin productivity tool) working folder 402 | .mfractor/ 403 | 404 | # Local History for Visual Studio 405 | .localhistory/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 MPowerKit 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 | -------------------------------------------------------------------------------- /MPowerKit.TabView.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34330.188 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MPowerKit.TabView", "MPowerKit.TabView\MPowerKit.TabView.csproj", "{A201F56D-C089-41A8-9CD4-5B5989169CED}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{24F2207E-39E4-49DC-917E-B6299339C957}" 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 | {A201F56D-C089-41A8-9CD4-5B5989169CED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {A201F56D-C089-41A8-9CD4-5B5989169CED}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {A201F56D-C089-41A8-9CD4-5B5989169CED}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {A201F56D-C089-41A8-9CD4-5B5989169CED}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {24F2207E-39E4-49DC-917E-B6299339C957}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {24F2207E-39E4-49DC-917E-B6299339C957}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {24F2207E-39E4-49DC-917E-B6299339C957}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 23 | {24F2207E-39E4-49DC-917E-B6299339C957}.Release|Any CPU.ActiveCfg = Release|Any CPU 24 | {24F2207E-39E4-49DC-917E-B6299339C957}.Release|Any CPU.Build.0 = Release|Any CPU 25 | {24F2207E-39E4-49DC-917E-B6299339C957}.Release|Any CPU.Deploy.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | GlobalSection(ExtensibilityGlobals) = postSolution 31 | SolutionGuid = {B717EC61-9026-4F80-84D9-9B9681F5B496} 32 | EndGlobalSection 33 | EndGlobal 34 | -------------------------------------------------------------------------------- /MPowerKit.TabView/Alignment.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.TabView; 2 | 3 | public enum Alignment 4 | { 5 | Top, 6 | Bottom, 7 | Left, 8 | Right 9 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/InverseBooleanConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace MPowerKit.TabView; 4 | 5 | public class InverseBooleanConverter : IValueConverter 6 | { 7 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) 8 | { 9 | if (value is bool boolean) 10 | { 11 | return !boolean; 12 | } 13 | 14 | return value; 15 | } 16 | 17 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) 18 | { 19 | throw new NotImplementedException(); 20 | } 21 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/ItemsPresenter.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.TabView; 2 | 3 | public class ItemsPresenter : ContentView 4 | { 5 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/MPowerKit.TabView.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0;net9.0 5 | true 6 | enable 7 | enable 8 | 9 | True 10 | MPowerKit.TabView 11 | 1.3.0 12 | MPowerKit,Alex Dobrynin 13 | Fully customizable .NET MAUI TabView 14 | MPowerKit 15 | https://github.com/MPowerKit/TabView 16 | https://github.com/MPowerKit/TabView 17 | tab view;tabview;maui;tabbedview;tab;tabbed;tabs 18 | LICENSE 19 | readme.md 20 | icon.png 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | True 30 | \ 31 | 32 | 33 | True 34 | \ 35 | 36 | 37 | True 38 | \ 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /MPowerKit.TabView/ScrollOrientationToStackOrientationConverter.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace MPowerKit.TabView; 4 | 5 | public class ScrollOrientationToStackOrientationConverter : IValueConverter 6 | { 7 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) 8 | { 9 | if (value is ScrollOrientation scrollOrientation) 10 | { 11 | return scrollOrientation switch 12 | { 13 | ScrollOrientation.Horizontal => StackOrientation.Horizontal, 14 | ScrollOrientation.Vertical => StackOrientation.Vertical, 15 | _ => throw new ArgumentOutOfRangeException(nameof(scrollOrientation), scrollOrientation, null) 16 | }; 17 | } 18 | 19 | return StackOrientation.Horizontal; 20 | } 21 | 22 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) 23 | { 24 | throw new NotImplementedException(); 25 | } 26 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/TabVIew.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.ObjectModel; 3 | using System.Collections.Specialized; 4 | using System.ComponentModel; 5 | using System.Runtime.CompilerServices; 6 | using System.Windows.Input; 7 | 8 | namespace MPowerKit.TabView; 9 | 10 | [ContentProperty("Tabs")] 11 | public class TabView : ContentView 12 | { 13 | protected Grid? ContentContainer; 14 | protected ScrollView? HeadersScroll; 15 | protected TabViewItem? PrevSelectedTabItem; 16 | protected Layout HeadersContainer; 17 | 18 | protected bool UseItemsSource => ItemsSource is not null; 19 | 20 | public ObservableCollection Tabs { get; } = []; 21 | 22 | protected Layout StackItemsLayout 23 | { 24 | get 25 | { 26 | var stack = new StackLayout() 27 | { 28 | VerticalOptions = LayoutOptions.Fill, 29 | HorizontalOptions = LayoutOptions.Fill, 30 | Spacing = 0, 31 | Orientation = StackOrientation.Horizontal 32 | }; 33 | 34 | stack.SetBinding(StackLayout.OrientationProperty, new Binding(ScrollView.OrientationProperty.PropertyName, 35 | source: new RelativeBindingSource(RelativeBindingSourceMode.FindAncestor, typeof(ScrollView)), 36 | converter: new ScrollOrientationToStackOrientationConverter())); 37 | 38 | return stack; 39 | } 40 | } 41 | 42 | public TabView() 43 | { 44 | Tabs.CollectionChanged += Tabs_CollectionChanged; 45 | } 46 | 47 | protected override void OnApplyTemplate() 48 | { 49 | base.OnApplyTemplate(); 50 | 51 | ContentContainer = GetTemplateChild("PART_ContentContainer") as Grid; 52 | HeadersScroll = GetTemplateChild("PART_HeadersScrollView") as ScrollView; 53 | 54 | InitHeaderBarLayout(); 55 | } 56 | 57 | protected virtual void InitHeaderBarLayout() 58 | { 59 | if (HeadersScroll == null || HeadersScroll.Content is not ItemsPresenter presenter) return; 60 | 61 | var newLayout = HeaderItemsLayout ?? StackItemsLayout; 62 | 63 | if (HeadersContainer != null) 64 | { 65 | foreach (var item in HeadersContainer.Children) 66 | { 67 | newLayout.Children.Add(item); 68 | } 69 | 70 | HeadersContainer.Children.Clear(); 71 | } 72 | 73 | HeadersContainer = newLayout; 74 | 75 | presenter.Content = HeadersContainer; 76 | } 77 | 78 | protected override void OnBindingContextChanged() 79 | { 80 | base.OnBindingContextChanged(); 81 | 82 | if (BindingContext is not null && !UseItemsSource) 83 | { 84 | foreach (var tab in Tabs) 85 | { 86 | if (tab.BindingContext != BindingContext) 87 | tab.BindingContext = BindingContext; 88 | } 89 | } 90 | } 91 | 92 | protected override void OnPropertyChanging([CallerMemberName] string? propertyName = null) 93 | { 94 | base.OnPropertyChanging(propertyName); 95 | 96 | if (propertyName == ItemsSourceProperty.PropertyName && ItemsSource is not null) 97 | { 98 | if (ItemsSource is INotifyCollectionChanged itemsSource) 99 | itemsSource.CollectionChanged -= ItemsSource_CollectionChanged; 100 | 101 | Tabs.Clear(); 102 | } 103 | else if (propertyName == SelectedTabIndexProperty.PropertyName) 104 | { 105 | PrevSelectedTabItem = Tabs.ElementAtOrDefault(SelectedTabIndex); 106 | } 107 | } 108 | 109 | protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null) 110 | { 111 | base.OnPropertyChanged(propertyName); 112 | 113 | if (propertyName == ItemsSourceProperty.PropertyName && ItemsSource is not null) 114 | { 115 | if (ItemsSource is INotifyCollectionChanged itemsSource) 116 | itemsSource.CollectionChanged += ItemsSource_CollectionChanged; 117 | 118 | InitItems(ItemsSource); 119 | } 120 | else if (propertyName == SelectedTabIndexProperty.PropertyName) 121 | { 122 | if (PrevSelectedTabItem is not null) PrevSelectedTabItem.IsSelected = false; 123 | 124 | var newTab = Tabs.ElementAtOrDefault(SelectedTabIndex); 125 | if (newTab is not null) 126 | { 127 | if (newTab.IsEnabled) 128 | { 129 | newTab.IsSelected = true; 130 | } 131 | else 132 | { 133 | SelectClosestEnabledTab(newTab); 134 | return; 135 | } 136 | } 137 | 138 | if (SelectedTabChangedCommand?.CanExecute(SelectedTabChangedCommandParameter) is true) 139 | SelectedTabChangedCommand.Execute(SelectedTabChangedCommandParameter); 140 | } 141 | else if (propertyName == ContentTemplateProperty.PropertyName && UseItemsSource) 142 | { 143 | foreach (var tab in Tabs) 144 | { 145 | var index = Tabs.IndexOf(tab); 146 | InitTabContentTemplate(tab.BindingContext, tab); 147 | } 148 | } 149 | else if (propertyName == HeaderItemsLayoutProperty.PropertyName) 150 | { 151 | InitHeaderBarLayout(); 152 | } 153 | } 154 | 155 | protected virtual void InitItems(IEnumerable source, int index = 0, bool useIndex = false) 156 | { 157 | if (source is null) return; 158 | 159 | foreach (var item in source) 160 | { 161 | var tabItem = new TabViewItem(); 162 | InitTabContentTemplate(item, tabItem); 163 | 164 | tabItem.BindingContext = item; 165 | tabItem.Header = item; 166 | 167 | if (useIndex) Tabs.Insert(index, tabItem); 168 | else Tabs.Add(tabItem); 169 | } 170 | } 171 | 172 | protected virtual void InitTabContentTemplate(object item, TabViewItem tabItem) 173 | { 174 | if (ContentTemplate is not null) 175 | { 176 | var template = ContentTemplate; 177 | if (ContentTemplate is DataTemplateSelector selector) template = selector.SelectTemplate(item, this); 178 | 179 | var tabContent = template.CreateContent() as View; 180 | tabContent!.BindingContext ??= item; 181 | 182 | tabItem.Content = tabContent; 183 | return; 184 | } 185 | 186 | tabItem.Content = new Label 187 | { 188 | Text = item.ToString() 189 | }; 190 | } 191 | 192 | protected virtual void ItemsSource_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) 193 | { 194 | switch (e.Action) 195 | { 196 | case NotifyCollectionChangedAction.Add: 197 | ItemsAdd(e); 198 | break; 199 | case NotifyCollectionChangedAction.Move: 200 | ItemsMove(e); 201 | break; 202 | case NotifyCollectionChangedAction.Remove: 203 | ItemsRemove(e); 204 | break; 205 | case NotifyCollectionChangedAction.Replace: 206 | ItemsReplace(e); 207 | break; 208 | case NotifyCollectionChangedAction.Reset: 209 | ItemsReset(e); 210 | break; 211 | } 212 | } 213 | 214 | protected virtual void ItemsAdd(NotifyCollectionChangedEventArgs e) 215 | { 216 | InitItems(e.NewItems!, e.NewStartingIndex, true); 217 | } 218 | 219 | protected virtual void ItemsMove(NotifyCollectionChangedEventArgs e) 220 | { 221 | Tabs.Move(e.OldStartingIndex, e.NewStartingIndex); 222 | } 223 | 224 | protected virtual void ItemsRemove(NotifyCollectionChangedEventArgs e) 225 | { 226 | if (e.OldItems is null) return; 227 | 228 | if (e.OldStartingIndex + e.OldItems.Count < SelectedTabIndex) 229 | { 230 | SelectedTabIndex -= e.OldItems.Count; 231 | } 232 | else if (SelectedTabIndex >= e.OldStartingIndex 233 | && SelectedTabIndex <= e.OldStartingIndex + e.OldItems.Count) 234 | { 235 | var newIndex = e.OldStartingIndex + e.OldItems.Count + 1; 236 | if (newIndex > Tabs.Count) newIndex = -1; 237 | SelectedTabIndex = newIndex; 238 | } 239 | 240 | foreach (var item in e.OldItems) 241 | { 242 | Tabs.RemoveAt(e.OldStartingIndex); 243 | } 244 | } 245 | 246 | protected virtual void ItemsReplace(NotifyCollectionChangedEventArgs e) 247 | { 248 | ItemsRemove(e); 249 | ItemsAdd(e); 250 | } 251 | 252 | protected virtual void ItemsReset(NotifyCollectionChangedEventArgs e) 253 | { 254 | foreach (var item in Tabs) 255 | { 256 | item.PropertyChanged -= TabItem_PropertyChanged; 257 | } 258 | 259 | Tabs.Clear(); 260 | 261 | InitItems(ItemsSource); 262 | } 263 | 264 | protected virtual void Tabs_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) 265 | { 266 | switch (e.Action) 267 | { 268 | case NotifyCollectionChangedAction.Add: 269 | { 270 | foreach (TabViewItem item in e.NewItems!) 271 | { 272 | item!.PropertyChanged += TabItem_PropertyChanged; 273 | 274 | HeadersContainer?.Children.Insert(e.NewStartingIndex, item.TabViewHeaderItem); 275 | ContentContainer?.Children.Insert(e.NewStartingIndex, item); 276 | } 277 | 278 | TabsInitialSelection(e); 279 | } 280 | break; 281 | case NotifyCollectionChangedAction.Move: 282 | { 283 | if (HeadersContainer is not null) 284 | { 285 | var header = HeadersContainer.Children.ElementAt(e.OldStartingIndex); 286 | HeadersContainer.Children.Remove(header); 287 | HeadersContainer.Children.Insert(e.NewStartingIndex, header); 288 | } 289 | 290 | if (ContentContainer is not null) 291 | { 292 | var content = ContentContainer.Children.ElementAt(e.OldStartingIndex); 293 | ContentContainer.Children.Remove(content); 294 | ContentContainer.Children.Insert(e.NewStartingIndex, content); 295 | } 296 | } 297 | break; 298 | case NotifyCollectionChangedAction.Remove: 299 | { 300 | foreach (TabViewItem item in e.OldItems!) 301 | { 302 | item!.PropertyChanged -= TabItem_PropertyChanged; 303 | 304 | HeadersContainer?.Children.RemoveAt(e.OldStartingIndex); 305 | ContentContainer?.Children.RemoveAt(e.OldStartingIndex); 306 | } 307 | } 308 | break; 309 | case NotifyCollectionChangedAction.Replace: 310 | break; 311 | case NotifyCollectionChangedAction.Reset: 312 | { 313 | HeadersContainer?.Children.Clear(); 314 | ContentContainer?.Children.Clear(); 315 | SelectedTabIndex = -1; 316 | } 317 | break; 318 | } 319 | } 320 | 321 | protected virtual void TabsInitialSelection(NotifyCollectionChangedEventArgs e) 322 | { 323 | if (SelectedTabIndex == -1) 324 | { 325 | if (Tabs.Any(t => t.IsSelected)) 326 | { 327 | SelectedTabIndex = Tabs.IndexOf(Tabs.First(t => t.IsSelected)); 328 | } 329 | else 330 | { 331 | var tab = Tabs.First(); 332 | if (!tab.IsEnabled) SelectClosestEnabledTab(tab); 333 | else SelectedTabIndex = 0; 334 | } 335 | } 336 | else 337 | { 338 | if (!Tabs.Any(t => t.IsSelected)) 339 | { 340 | var tab = Tabs.ElementAtOrDefault(SelectedTabIndex); 341 | if (tab is null) 342 | { 343 | if (Tabs.Count == 0) SelectedTabIndex = -1; 344 | else SelectedTabIndex = 0; 345 | return; 346 | } 347 | if (!tab.IsEnabled) SelectClosestEnabledTab(tab); 348 | else tab.IsSelected = true; 349 | } 350 | else if (e.NewStartingIndex <= SelectedTabIndex) 351 | SelectedTabIndex += (e.NewItems?.Count ?? 0) - (e.OldItems?.Count ?? 0); 352 | } 353 | } 354 | 355 | protected virtual void TabItem_PropertyChanged(object? sender, PropertyChangedEventArgs e) 356 | { 357 | var tab = (sender as TabViewItem)!; 358 | 359 | if (e.PropertyName == TabViewItem.IsSelectedProperty.PropertyName && tab.IsSelected) 360 | { 361 | if (!tab.IsEnabled) 362 | { 363 | SelectClosestEnabledTab(tab); 364 | return; 365 | } 366 | 367 | SelectedTabIndex = Tabs.IndexOf(tab); 368 | 369 | if (HeadersScroll is null || !ScrollToSelectedTab) return; 370 | 371 | if (HeaderBarAlignment is Alignment.Top or Alignment.Bottom 372 | && HeadersContainer.Width > HeadersScroll.Width) 373 | { 374 | var max = HeadersContainer.Width - HeadersScroll.Width; 375 | var scrollTo = tab.TabViewHeaderItem.X - (HeadersScroll.Width - tab.TabViewHeaderItem.Width) / 2.0; 376 | scrollTo = Math.Max(0d, Math.Min(max, scrollTo)); 377 | 378 | HeadersScroll.ScrollToAsync(scrollTo, 0d, true); 379 | } 380 | else if (HeaderBarAlignment is Alignment.Left or Alignment.Right 381 | && HeadersContainer.Height > HeadersScroll.Height) 382 | { 383 | var max = HeadersContainer.Height - HeadersScroll.Height; 384 | var scrollTo = tab.TabViewHeaderItem.Y - (HeadersScroll.Height - tab.TabViewHeaderItem.Height) / 2.0; 385 | scrollTo = Math.Max(0d, Math.Min(max, scrollTo)); 386 | 387 | HeadersScroll.ScrollToAsync(0d, scrollTo, true); 388 | } 389 | } 390 | else if (e.PropertyName == TabViewItem.IsEnabledProperty.PropertyName) 391 | { 392 | if (!tab.IsEnabled && tab.IsSelected) SelectClosestEnabledTab(tab); 393 | else if (tab.IsEnabled && !Tabs.Any(t => t.IsSelected)) 394 | { 395 | var index = Tabs.IndexOf(tab); 396 | SelectedTabIndex = index; 397 | } 398 | } 399 | } 400 | 401 | protected virtual void SelectClosestEnabledTab(TabViewItem tab) 402 | { 403 | var tabs = Tabs.Where(t => t.IsEnabled || t == tab).ToList(); 404 | 405 | if (tabs.Count == 1) 406 | { 407 | SelectedTabIndex = -1; 408 | return; 409 | } 410 | 411 | var index = tabs.IndexOf(tab); 412 | 413 | tabs[index + (index == tabs.Count - 1 ? -1 : 1)].IsSelected = true; 414 | } 415 | 416 | #region HideTabsWhenDisabled 417 | public bool HideTabsWhenDisabled 418 | { 419 | get { return (bool)GetValue(HideTabsWhenDisabledProperty); } 420 | set { SetValue(HideTabsWhenDisabledProperty, value); } 421 | } 422 | 423 | public static readonly BindableProperty HideTabsWhenDisabledProperty = 424 | BindableProperty.Create( 425 | nameof(HideTabsWhenDisabled), 426 | typeof(bool), 427 | typeof(TabView), 428 | true 429 | ); 430 | #endregion 431 | 432 | #region HeaderItemsLayout 433 | public Layout HeaderItemsLayout 434 | { 435 | get { return (Layout)GetValue(HeaderItemsLayoutProperty); } 436 | set { SetValue(HeaderItemsLayoutProperty, value); } 437 | } 438 | 439 | public static readonly BindableProperty HeaderItemsLayoutProperty = 440 | BindableProperty.Create( 441 | nameof(HeaderItemsLayout), 442 | typeof(Layout), 443 | typeof(TabView) 444 | ); 445 | #endregion 446 | 447 | #region ScrollToSelectedTab 448 | public bool ScrollToSelectedTab 449 | { 450 | get { return (bool)GetValue(ScrollToSelectedTabProperty); } 451 | set { SetValue(ScrollToSelectedTabProperty, value); } 452 | } 453 | 454 | public static readonly BindableProperty ScrollToSelectedTabProperty = 455 | BindableProperty.Create( 456 | nameof(ScrollToSelectedTab), 457 | typeof(bool), 458 | typeof(TabView), 459 | true 460 | ); 461 | #endregion 462 | 463 | #region ContentBackgroundColor 464 | public Color ContentBackgroundColor 465 | { 466 | get { return (Color)GetValue(ContentBackgroundColorProperty); } 467 | set { SetValue(ContentBackgroundColorProperty, value); } 468 | } 469 | 470 | public static readonly BindableProperty ContentBackgroundColorProperty = 471 | BindableProperty.Create( 472 | nameof(ContentBackgroundColor), 473 | typeof(Color), 474 | typeof(TabView), 475 | Colors.Transparent 476 | ); 477 | #endregion 478 | 479 | #region HeaderBarBackgroundColor 480 | public Color HeaderBarBackgroundColor 481 | { 482 | get { return (Color)GetValue(HeaderBarBackgroundColorProperty); } 483 | set { SetValue(HeaderBarBackgroundColorProperty, value); } 484 | } 485 | 486 | public static readonly BindableProperty HeaderBarBackgroundColorProperty = 487 | BindableProperty.Create( 488 | nameof(HeaderBarBackgroundColor), 489 | typeof(Color), 490 | typeof(TabView), 491 | Colors.Transparent 492 | ); 493 | #endregion 494 | 495 | #region SelectedHeaderBackgroundColor 496 | public Color SelectedHeaderBackgroundColor 497 | { 498 | get { return (Color)GetValue(SelectedHeaderBackgroundColorProperty); } 499 | set { SetValue(SelectedHeaderBackgroundColorProperty, value); } 500 | } 501 | 502 | public static readonly BindableProperty SelectedHeaderBackgroundColorProperty = 503 | BindableProperty.Create( 504 | nameof(SelectedHeaderBackgroundColor), 505 | typeof(Color), 506 | typeof(TabView), 507 | Colors.Blue 508 | ); 509 | #endregion 510 | 511 | #region HeaderBackgroundColor 512 | public Color HeaderBackgroundColor 513 | { 514 | get { return (Color)GetValue(HeaderBackgroundColorProperty); } 515 | set { SetValue(HeaderBackgroundColorProperty, value); } 516 | } 517 | 518 | public static readonly BindableProperty HeaderBackgroundColorProperty = 519 | BindableProperty.Create( 520 | nameof(HeaderBackgroundColor), 521 | typeof(Color), 522 | typeof(TabView), 523 | Colors.Transparent 524 | ); 525 | #endregion 526 | 527 | #region HeaderHeightRequest 528 | public double HeaderHeightRequest 529 | { 530 | get { return (double)GetValue(HeaderHeightRequestProperty); } 531 | set { SetValue(HeaderHeightRequestProperty, value); } 532 | } 533 | 534 | public static readonly BindableProperty HeaderHeightRequestProperty = 535 | BindableProperty.Create( 536 | nameof(HeaderHeightRequest), 537 | typeof(double), 538 | typeof(TabView), 539 | 50.0 540 | ); 541 | #endregion 542 | 543 | #region HeaderFontFamily 544 | public string HeaderFontFamily 545 | { 546 | get { return (string)GetValue(HeaderFontFamilyProperty); } 547 | set { SetValue(HeaderFontFamilyProperty, value); } 548 | } 549 | 550 | public static readonly BindableProperty HeaderFontFamilyProperty = 551 | BindableProperty.Create( 552 | nameof(HeaderFontFamily), 553 | typeof(string), 554 | typeof(TabView) 555 | ); 556 | #endregion 557 | 558 | #region HeaderFontSize 559 | public double HeaderFontSize 560 | { 561 | get { return (double)GetValue(HeaderFontSizeProperty); } 562 | set { SetValue(HeaderFontSizeProperty, value); } 563 | } 564 | 565 | public static readonly BindableProperty HeaderFontSizeProperty = 566 | BindableProperty.Create( 567 | nameof(HeaderFontSize), 568 | typeof(double), 569 | typeof(TabView), 570 | 14.0 571 | ); 572 | #endregion 573 | 574 | #region HeaderFontAttributes 575 | public FontAttributes HeaderFontAttributes 576 | { 577 | get { return (FontAttributes)GetValue(HeaderFontAttributesProperty); } 578 | set { SetValue(HeaderFontAttributesProperty, value); } 579 | } 580 | 581 | public static readonly BindableProperty HeaderFontAttributesProperty = 582 | BindableProperty.Create( 583 | nameof(HeaderFontAttributes), 584 | typeof(FontAttributes), 585 | typeof(TabView), 586 | FontAttributes.None 587 | ); 588 | #endregion 589 | 590 | #region HeaderTextColor 591 | public Color HeaderTextColor 592 | { 593 | get { return (Color)GetValue(HeaderTextColorProperty); } 594 | set { SetValue(HeaderTextColorProperty, value); } 595 | } 596 | 597 | public static readonly BindableProperty HeaderTextColorProperty = 598 | BindableProperty.Create( 599 | nameof(HeaderTextColor), 600 | typeof(Color), 601 | typeof(TabView), 602 | Colors.Black 603 | ); 604 | #endregion 605 | 606 | #region SelectedTabIndex 607 | public int SelectedTabIndex 608 | { 609 | get { return (int)GetValue(SelectedTabIndexProperty); } 610 | set { SetValue(SelectedTabIndexProperty, value); } 611 | } 612 | 613 | public static readonly BindableProperty SelectedTabIndexProperty = 614 | BindableProperty.Create( 615 | nameof(SelectedTabIndex), 616 | typeof(int), 617 | typeof(TabView), 618 | -1 619 | ); 620 | #endregion 621 | 622 | #region SelectedHeaderTemplate 623 | public DataTemplate SelectedHeaderTemplate 624 | { 625 | get { return (DataTemplate)GetValue(SelectedHeaderTemplateProperty); } 626 | set { SetValue(SelectedHeaderTemplateProperty, value); } 627 | } 628 | 629 | public static readonly BindableProperty SelectedHeaderTemplateProperty = 630 | BindableProperty.Create( 631 | nameof(SelectedHeaderTemplate), 632 | typeof(DataTemplate), 633 | typeof(TabView) 634 | ); 635 | #endregion 636 | 637 | #region HeaderTemplate 638 | public DataTemplate HeaderTemplate 639 | { 640 | get { return (DataTemplate)GetValue(HeaderTemplateProperty); } 641 | set { SetValue(HeaderTemplateProperty, value); } 642 | } 643 | 644 | public static readonly BindableProperty HeaderTemplateProperty = 645 | BindableProperty.Create( 646 | nameof(HeaderTemplate), 647 | typeof(DataTemplate), 648 | typeof(TabView) 649 | ); 650 | #endregion 651 | 652 | #region ContentTemplate 653 | public DataTemplate ContentTemplate 654 | { 655 | get { return (DataTemplate)GetValue(ContentTemplateProperty); } 656 | set { SetValue(ContentTemplateProperty, value); } 657 | } 658 | 659 | public static readonly BindableProperty ContentTemplateProperty = 660 | BindableProperty.Create( 661 | nameof(ContentTemplate), 662 | typeof(DataTemplate), 663 | typeof(TabView) 664 | ); 665 | #endregion 666 | 667 | #region ItemsSource 668 | public IEnumerable ItemsSource 669 | { 670 | get { return (IEnumerable)GetValue(ItemsSourceProperty); } 671 | set { SetValue(ItemsSourceProperty, value); } 672 | } 673 | 674 | public static readonly BindableProperty ItemsSourceProperty = 675 | BindableProperty.Create( 676 | nameof(ItemsSource), 677 | typeof(IEnumerable), 678 | typeof(TabView) 679 | ); 680 | #endregion 681 | 682 | #region SelectedTabChangedCommand 683 | public ICommand SelectedTabChangedCommand 684 | { 685 | get { return (ICommand)GetValue(SelectedTabChangedCommandProperty); } 686 | set { SetValue(SelectedTabChangedCommandProperty, value); } 687 | } 688 | 689 | public static readonly BindableProperty SelectedTabChangedCommandProperty = 690 | BindableProperty.Create( 691 | nameof(SelectedTabChangedCommand), 692 | typeof(ICommand), 693 | typeof(TabView) 694 | ); 695 | #endregion 696 | 697 | #region SelectedTabChangedCommandParameter 698 | public object SelectedTabChangedCommandParameter 699 | { 700 | get { return (object)GetValue(SelectedTabChangedCommandParameterProperty); } 701 | set { SetValue(SelectedTabChangedCommandParameterProperty, value); } 702 | } 703 | 704 | public static readonly BindableProperty SelectedTabChangedCommandParameterProperty = 705 | BindableProperty.Create( 706 | nameof(SelectedTabChangedCommandParameter), 707 | typeof(object), 708 | typeof(TabView) 709 | ); 710 | #endregion 711 | 712 | #region HeaderBarAlignment 713 | public Alignment HeaderBarAlignment 714 | { 715 | get { return (Alignment)GetValue(HeaderBarAlignmentProperty); } 716 | set { SetValue(HeaderBarAlignmentProperty, value); } 717 | } 718 | 719 | public static readonly BindableProperty HeaderBarAlignmentProperty = 720 | BindableProperty.Create( 721 | nameof(HeaderBarAlignment), 722 | typeof(Alignment), 723 | typeof(TabView), 724 | Alignment.Top 725 | ); 726 | #endregion 727 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/TabViewHeaderItem.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | 3 | namespace MPowerKit.TabView; 4 | 5 | public class TabViewHeaderItem : Grid 6 | { 7 | protected readonly DataTemplate StringTemplate = new(() => 8 | { 9 | var lbl = new Label() 10 | { 11 | VerticalOptions = LayoutOptions.Center, 12 | HorizontalOptions = LayoutOptions.Center, 13 | VerticalTextAlignment = TextAlignment.Center, 14 | HorizontalTextAlignment = TextAlignment.Center 15 | }; 16 | lbl.SetBinding(Label.TextProperty, "."); 17 | lbl.SetBinding(Label.TextColorProperty, new Binding(TabView.HeaderTextColorProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 18 | lbl.SetBinding(Label.FontFamilyProperty, new Binding(TabView.HeaderFontFamilyProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 19 | lbl.SetBinding(Label.FontSizeProperty, new Binding(TabView.HeaderFontSizeProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 20 | lbl.SetBinding(Label.FontAttributesProperty, new Binding(TabView.HeaderFontAttributesProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 21 | return new ContentView() 22 | { 23 | Content = lbl, 24 | VerticalOptions = LayoutOptions.Fill, 25 | HorizontalOptions = LayoutOptions.Fill, 26 | Padding = new Thickness(20, 10) 27 | }; 28 | }); 29 | 30 | protected View? SelectedView; 31 | protected View? UnselectedView; 32 | 33 | public TabViewHeaderItem() 34 | { 35 | var tap = new TapGestureRecognizer(); 36 | tap.Tapped += Tap_Tapped; 37 | GestureRecognizers.Add(tap); 38 | 39 | SetBinding(SelectedContentTemplateProperty, new Binding(TabView.SelectedHeaderTemplateProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 40 | SetBinding(ContentTemplateProperty, new Binding(TabView.HeaderTemplateProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 41 | SetBinding(HideWhenDisabledProperty, new Binding(TabView.HideTabsWhenDisabledProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 42 | SetBinding(BackgroundColorProperty, new Binding(TabView.HeaderBackgroundColorProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 43 | } 44 | 45 | private void Tap_Tapped(object? sender, EventArgs e) 46 | { 47 | if (!IsEnabled) return; 48 | 49 | if (!IsSelected) IsSelected = true; 50 | } 51 | 52 | protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null) 53 | { 54 | base.OnPropertyChanged(propertyName); 55 | 56 | if (propertyName == HideWhenDisabledProperty.PropertyName) 57 | { 58 | IsVisible = !HideWhenDisabled || IsEnabled; 59 | return; 60 | } 61 | 62 | if (propertyName == HeaderContentProperty.PropertyName && HeaderContent is View content) 63 | { 64 | Children.Clear(); 65 | Children.Add(content); 66 | } 67 | 68 | if (HeaderContent is View) return; 69 | 70 | else if (propertyName == IsSelectedProperty.PropertyName) 71 | { 72 | SetBinding(View.BackgroundColorProperty, new Binding(IsSelected 73 | ? TabView.SelectedHeaderBackgroundColorProperty.PropertyName 74 | : TabView.HeaderBackgroundColorProperty.PropertyName, source: RelativeBindingSource.TemplatedParent)); 75 | } 76 | else if (propertyName == HeaderContentProperty.PropertyName 77 | || propertyName == SelectedContentTemplateProperty.PropertyName 78 | || propertyName == ContentTemplateProperty.PropertyName) 79 | { 80 | InitContent(); 81 | } 82 | } 83 | 84 | public virtual void InitContent() 85 | { 86 | var unselectedTemplate = ContentTemplate != null 87 | ? (ContentTemplate is DataTemplateSelector selectorU ? selectorU.SelectTemplate(HeaderContent, null) : ContentTemplate) 88 | : StringTemplate; 89 | 90 | var selectedTemplate = SelectedContentTemplate != null 91 | ? (SelectedContentTemplate is DataTemplateSelector selectorS ? selectorS.SelectTemplate(HeaderContent, null) : SelectedContentTemplate) 92 | : unselectedTemplate; 93 | 94 | var context = HeaderContent; 95 | context ??= "Empty Header"; 96 | 97 | SelectedView = selectedTemplate.CreateContent() as View; 98 | SelectedView!.BindingContext = selectedTemplate == StringTemplate ? context.ToString() : context; 99 | 100 | UnselectedView = unselectedTemplate.CreateContent() as View; 101 | UnselectedView!.BindingContext = unselectedTemplate == StringTemplate ? context.ToString() : context; 102 | 103 | SelectedView.SetBinding(View.IsVisibleProperty, new Binding(IsSelectedProperty.PropertyName, source: this)); 104 | UnselectedView.SetBinding(View.IsVisibleProperty, new Binding(IsSelectedProperty.PropertyName, source: this, converter: new InverseBooleanConverter())); 105 | 106 | Children.Clear(); 107 | Children.Add(SelectedView); 108 | Children.Add(UnselectedView); 109 | } 110 | 111 | #region IsSelected 112 | public bool IsSelected 113 | { 114 | get { return (bool)GetValue(IsSelectedProperty); } 115 | set { SetValue(IsSelectedProperty, value); } 116 | } 117 | 118 | public static readonly BindableProperty IsSelectedProperty = 119 | BindableProperty.Create( 120 | nameof(IsSelected), 121 | typeof(bool), 122 | typeof(TabViewHeaderItem) 123 | ); 124 | #endregion 125 | 126 | #region HeaderContent 127 | public object HeaderContent 128 | { 129 | get { return (object)GetValue(HeaderContentProperty); } 130 | set { SetValue(HeaderContentProperty, value); } 131 | } 132 | 133 | public static readonly BindableProperty HeaderContentProperty = 134 | BindableProperty.Create( 135 | nameof(HeaderContent), 136 | typeof(object), 137 | typeof(TabViewHeaderItem) 138 | ); 139 | #endregion 140 | 141 | #region SelectedContentTemplate 142 | public DataTemplate SelectedContentTemplate 143 | { 144 | get { return (DataTemplate)GetValue(SelectedContentTemplateProperty); } 145 | set { SetValue(SelectedContentTemplateProperty, value); } 146 | } 147 | 148 | public static readonly BindableProperty SelectedContentTemplateProperty = 149 | BindableProperty.Create( 150 | nameof(SelectedContentTemplate), 151 | typeof(DataTemplate), 152 | typeof(TabViewHeaderItem) 153 | ); 154 | #endregion 155 | 156 | #region ContentTemplate 157 | public DataTemplate ContentTemplate 158 | { 159 | get { return (DataTemplate)GetValue(ContentTemplateProperty); } 160 | set { SetValue(ContentTemplateProperty, value); } 161 | } 162 | 163 | public static readonly BindableProperty ContentTemplateProperty = 164 | BindableProperty.Create( 165 | nameof(ContentTemplate), 166 | typeof(DataTemplate), 167 | typeof(TabViewHeaderItem) 168 | ); 169 | #endregion 170 | 171 | #region HideWhenDisabled 172 | public bool HideWhenDisabled 173 | { 174 | get { return (bool)GetValue(HideWhenDisabledProperty); } 175 | set { SetValue(HideWhenDisabledProperty, value); } 176 | } 177 | 178 | public static readonly BindableProperty HideWhenDisabledProperty = 179 | BindableProperty.Create( 180 | nameof(HideWhenDisabled), 181 | typeof(bool), 182 | typeof(TabViewHeaderItem), 183 | true 184 | ); 185 | #endregion 186 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/TabViewItem.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | using System.Runtime.CompilerServices; 3 | 4 | namespace MPowerKit.TabView; 5 | 6 | public class TabViewItem : ContentView 7 | { 8 | public TabViewHeaderItem TabViewHeaderItem { get; protected set; } = []; 9 | 10 | public TabViewItem() 11 | { 12 | TabViewHeaderItem.PropertyChanged += TabViewHeaderItem_PropertyChanged; 13 | 14 | SetBinding(IsVisibleProperty, new Binding(IsSelectedProperty.PropertyName, source: this)); 15 | TabViewHeaderItem.SetBinding(View.IsEnabledProperty, new Binding(IsEnabledProperty.PropertyName, mode: BindingMode.TwoWay, source: this)); 16 | TabViewHeaderItem.SetBinding(TabViewHeaderItem.HeaderContentProperty, new Binding(HeaderProperty.PropertyName, source: this)); 17 | TabViewHeaderItem.SetBinding(Grid.ColumnProperty, new Binding(ColumnProperty.PropertyName, source: this)); 18 | TabViewHeaderItem.SetBinding(Grid.RowProperty, new Binding(RowProperty.PropertyName, source: this)); 19 | } 20 | 21 | private void TabViewHeaderItem_PropertyChanged(object? sender, PropertyChangedEventArgs e) 22 | { 23 | if (e.PropertyName == TabViewHeaderItem.IsSelectedProperty.PropertyName) 24 | { 25 | IsSelected = TabViewHeaderItem.IsSelected; 26 | } 27 | } 28 | 29 | protected override void OnPropertyChanged([CallerMemberName] string? propertyName = null) 30 | { 31 | base.OnPropertyChanged(propertyName); 32 | 33 | if (propertyName == IsEnabledProperty.PropertyName 34 | || propertyName == IsSelectedProperty.PropertyName 35 | && !IsEnabled && IsSelected) 36 | { 37 | IsSelected = false; 38 | } 39 | 40 | if (propertyName == IsSelectedProperty.PropertyName) 41 | { 42 | TabViewHeaderItem.IsSelected = IsSelected; 43 | } 44 | } 45 | 46 | #region IsSelected 47 | public bool IsSelected 48 | { 49 | get { return (bool)GetValue(IsSelectedProperty); } 50 | set { SetValue(IsSelectedProperty, value); } 51 | } 52 | 53 | public static readonly BindableProperty IsSelectedProperty = 54 | BindableProperty.Create( 55 | nameof(IsSelected), 56 | typeof(bool), 57 | typeof(TabViewItem) 58 | ); 59 | #endregion 60 | 61 | #region Header 62 | public object Header 63 | { 64 | get { return (object)GetValue(HeaderProperty); } 65 | set { SetValue(HeaderProperty, value); } 66 | } 67 | 68 | public static readonly BindableProperty HeaderProperty = 69 | BindableProperty.Create( 70 | nameof(Header), 71 | typeof(object), 72 | typeof(TabViewItem) 73 | ); 74 | #endregion 75 | 76 | #region Column 77 | public int Column 78 | { 79 | get { return (int)GetValue(ColumnProperty); } 80 | set { SetValue(ColumnProperty, value); } 81 | } 82 | 83 | public static readonly BindableProperty ColumnProperty = 84 | BindableProperty.Create( 85 | nameof(Column), 86 | typeof(int), 87 | typeof(TabViewItem) 88 | ); 89 | #endregion 90 | 91 | #region Row 92 | public int Row 93 | { 94 | get { return (int)GetValue(RowProperty); } 95 | set { SetValue(RowProperty, value); } 96 | } 97 | 98 | public static readonly BindableProperty RowProperty = 99 | BindableProperty.Create( 100 | nameof(Row), 101 | typeof(int), 102 | typeof(TabViewItem) 103 | ); 104 | #endregion 105 | } -------------------------------------------------------------------------------- /MPowerKit.TabView/TabViewStyle.xaml: -------------------------------------------------------------------------------- 1 |  2 | 6 | 7 | 148 | -------------------------------------------------------------------------------- /MPowerKit.TabView/TabViewStyle.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace MPowerKit.TabView; 2 | 3 | public partial class TabViewStyle 4 | { 5 | public TabViewStyle() 6 | { 7 | InitializeComponent(); 8 | } 9 | } -------------------------------------------------------------------------------- /Sample/App.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Sample/App.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sample 2 | { 3 | public partial class App : Application 4 | { 5 | public App() 6 | { 7 | InitializeComponent(); 8 | 9 | MainPage = new AppShell(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Sample/AppShell.xaml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Sample/AppShell.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Sample 2 | { 3 | public partial class AppShell : Shell 4 | { 5 | public AppShell() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sample/MainPage.xaml: -------------------------------------------------------------------------------- 1 |  2 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 53 | 54 | 55 | 56 | 58 | 61 | 66 | 67 | 68 | 70 | 71 | 73 | 91 | 96 | 97 | 98 | 99 | 100 | 104 | 105 | 106 | 108 | 109 | 114 | 115 | 116 | 117 | 118 | 121 | 122 | 124 | 125 | 126 | 127 | 129 | 134 | 135 | 136 | 137 | 138 | 140 | 145 | 146 | 147 | 148 | 149 | 150 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /Sample/MainPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.ObjectModel; 2 | 3 | namespace Sample; 4 | 5 | public class PersonViewModel 6 | { 7 | public string FirstName { get; set; } 8 | public string LastName { get; set; } 9 | } 10 | 11 | public partial class MainPage : ContentPage 12 | { 13 | public MainPage() 14 | { 15 | Title = "Main Page"; 16 | 17 | ObservableCollection people = []; 18 | for (int i = 0; i < 5; i++) 19 | { 20 | people.Add(new PersonViewModel() { FirstName = $"FirstName {i}", LastName = $"LastName {i}" }); 21 | } 22 | People = people; 23 | 24 | InitializeComponent(); 25 | } 26 | 27 | public ObservableCollection People { get; set; } = []; 28 | } -------------------------------------------------------------------------------- /Sample/MauiProgram.cs: -------------------------------------------------------------------------------- 1 | namespace Sample 2 | { 3 | public static class MauiProgram 4 | { 5 | public static MauiApp CreateMauiApp() 6 | { 7 | var builder = MauiApp.CreateBuilder(); 8 | builder 9 | .UseMauiApp() 10 | .ConfigureFonts(fonts => 11 | { 12 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); 13 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); 14 | }); 15 | 16 | return builder.Build(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/MainActivity.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Content.PM; 3 | using Android.OS; 4 | 5 | namespace Sample 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 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/MainApplication.cs: -------------------------------------------------------------------------------- 1 | using Android.App; 2 | using Android.Runtime; 3 | 4 | namespace Sample 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 | -------------------------------------------------------------------------------- /Sample/Platforms/Android/Resources/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #512BD4 4 | #2B0B98 5 | #2B0B98 6 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace Sample 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/Entitlements.plist: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | com.apple.security.app-sandbox 8 | 9 | 10 | com.apple.security.network.client 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | UIDeviceFamily 15 | 16 | 2 17 | 18 | UIRequiredDeviceCapabilities 19 | 20 | arm64 21 | 22 | UISupportedInterfaceOrientations 23 | 24 | UIInterfaceOrientationPortrait 25 | UIInterfaceOrientationLandscapeLeft 26 | UIInterfaceOrientationLandscapeRight 27 | 28 | UISupportedInterfaceOrientations~ipad 29 | 30 | UIInterfaceOrientationPortrait 31 | UIInterfaceOrientationPortraitUpsideDown 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | XSAppIconAssets 36 | Assets.xcassets/appicon.appiconset 37 | 38 | 39 | -------------------------------------------------------------------------------- /Sample/Platforms/MacCatalyst/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | 3 | using UIKit; 4 | 5 | namespace Sample 6 | { 7 | public class Program 8 | { 9 | // This is the main entry point of the application. 10 | static void Main(string[] args) 11 | { 12 | // if you want to use a different Application Delegate class from "AppDelegate" 13 | // you can specify it here. 14 | UIApplication.Main(args, null, typeof(AppDelegate)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sample/Platforms/Tizen/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | using Microsoft.Maui; 4 | using Microsoft.Maui.Hosting; 5 | 6 | namespace Sample 7 | { 8 | internal class Program : MauiApplication 9 | { 10 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 11 | 12 | static void Main(string[] args) 13 | { 14 | var app = new Program(); 15 | app.Run(args); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/Platforms/Windows/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /Sample/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 Sample.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 | -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/Platforms/Windows/app.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | true/PM 12 | PerMonitorV2, PerMonitor 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Sample/Platforms/iOS/AppDelegate.cs: -------------------------------------------------------------------------------- 1 | using Foundation; 2 | 3 | namespace Sample 4 | { 5 | [Register("AppDelegate")] 6 | public class AppDelegate : MauiUIApplicationDelegate 7 | { 8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/Platforms/iOS/Program.cs: -------------------------------------------------------------------------------- 1 | using ObjCRuntime; 2 | 3 | using UIKit; 4 | 5 | namespace Sample 6 | { 7 | public class Program 8 | { 9 | // This is the main entry point of the application. 10 | static void Main(string[] args) 11 | { 12 | // if you want to use a different Application Delegate class from "AppDelegate" 13 | // you can specify it here. 14 | UIApplication.Main(args, null, typeof(AppDelegate)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Sample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "Windows Machine": { 4 | "commandName": "MsixPackage", 5 | "nativeDebugging": false 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Sample/Resources/AppIcon/appicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Sample/Resources/AppIcon/appiconfg.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample/Resources/Fonts/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/TabView/b316b330713f9d605a4176755197d6d736b8158e/Sample/Resources/Fonts/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /Sample/Resources/Fonts/OpenSans-Semibold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/TabView/b316b330713f9d605a4176755197d6d736b8158e/Sample/Resources/Fonts/OpenSans-Semibold.ttf -------------------------------------------------------------------------------- /Sample/Resources/Images/dotnet_bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/TabView/b316b330713f9d605a4176755197d6d736b8158e/Sample/Resources/Images/dotnet_bot.png -------------------------------------------------------------------------------- /Sample/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 | -------------------------------------------------------------------------------- /Sample/Resources/Splash/splash.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Sample/Resources/Styles/Colors.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 8 | 9 | #512BD4 10 | #ac99ea 11 | #242424 12 | #DFD8F7 13 | #9880e5 14 | #2B0B98 15 | 16 | White 17 | Black 18 | #D600AA 19 | #190649 20 | #1f1f1f 21 | 22 | #E1E1E1 23 | #C8C8C8 24 | #ACACAC 25 | #919191 26 | #6E6E6E 27 | #404040 28 | #212121 29 | #141414 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Sample/Resources/Styles/Styles.xaml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 10 | 11 | 15 | 16 | 21 | 22 | 25 | 26 | 51 | 52 | 69 | 70 | 90 | 91 | 112 | 113 | 134 | 135 | 140 | 141 | 162 | 163 | 181 | 182 | 185 | 186 | 192 | 193 | 199 | 200 | 204 | 205 | 227 | 228 | 243 | 244 | 264 | 265 | 268 | 269 | 292 | 293 | 313 | 314 | 320 | 321 | 340 | 341 | 344 | 345 | 373 | 374 | 394 | 395 | 399 | 400 | 412 | 413 | 418 | 419 | 425 | 426 | 427 | -------------------------------------------------------------------------------- /Sample/Sample.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 | 9 | 14 | 15 | 16 | Exe 17 | Sample 18 | true 19 | true 20 | enable 21 | enable 22 | 23 | 24 | Sample 25 | 26 | 27 | com.companyname.sample 28 | 29 | 30 | 1.0 31 | 1 32 | 33 | 11.0 34 | 13.1 35 | 21.0 36 | 10.0.17763.0 37 | 10.0.17763.0 38 | 6.5 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 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MPowerKit/TabView/b316b330713f9d605a4176755197d6d736b8158e/icon.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # MPowerKit.TabView 2 | Fully customizable .NET MAUI TabView 3 | 4 | It is written using .NET MAUI without native code and it is fully compatible with all platforms MAUI supports 5 | 6 | [![NuGet](https://img.shields.io/nuget/v/MPowerKit.TabView.svg?maxAge=2592000)](https://www.nuget.org/packages/MPowerKit.TabView) 7 | 8 | [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/alexdobrynin) 9 | 10 | ### Initialize: 11 | Make sure to initialize the UI of the TabView inside your App.xaml file: 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | ### Usage: 24 | 25 | You can create tabs from markup or from ViewModel specifying ItemsSource and describing DataTemplate and header templates in xaml. 26 | Note: ItemsSource has higher priority than directly markup tab creation. 27 | 28 | ### Example of usage: 29 | 30 | Here described two types of usage: 31 | https://github.com/MPowerKit/TabView/tree/main/Sample/MainPage.xaml 32 | 33 | ### Note: 34 | You cannot use typeof Page as tab template. 35 | --------------------------------------------------------------------------------