Vapolia.SegmentedViews
1.0.6
Prefix Reserved
dotnet add package Vapolia.SegmentedViews --version 1.0.6
NuGet\Install-Package Vapolia.SegmentedViews -Version 1.0.6
<PackageReference Include="Vapolia.SegmentedViews" Version="1.0.6" />
paket add Vapolia.SegmentedViews --version 1.0.6
#r "nuget: Vapolia.SegmentedViews, 1.0.6"
// Install Vapolia.SegmentedViews as a Cake Addin #addin nuget:?package=Vapolia.SegmentedViews&version=1.0.6 // Install Vapolia.SegmentedViews as a Cake Tool #tool nuget:?package=Vapolia.SegmentedViews&version=1.0.6
Vapolia.SegmentedViews
dotnet add package Vapolia.SegmentedViews
builder.UseSegmentedView();
Platforms:
- Android
- iOS
Supports both static segments and ItemsSource
to build segments dynamically.
Quick start
Add the above nuget package to your Maui project
then add this line to your maui app builder:
using Vapolia.SegmentedViews;
...
builder.UseSegmentedView();
Examples
See the SampleApp in this repo.
Declare the namespace:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
...
xmlns:segmented="https://vapolia.eu/Vapolia.SegmentedViews">
Add a static segment view:
<segmented:SegmentedView
x:Name="TheSegmentView"
SelectedIndex="0"
SelectedTextColor="White" TextColor="Black" SelectedBackgroundColor="Blue" DisabledColor="LightGray"
SelectionChangedCommand="{Binding SegmentSelectionChangedCommand}"
SelectedItem="{Binding SegmentSelectedItem}">
<segmented:Segment Item="Item1" />
<segmented:Segment Item="Item2" />
<segmented:Segment Item="Item3" />
<segmented:Segment Item="Item4" />
<segmented:Segment Item="{Binding Item5Title}" />
</segmented:SegmentedView>
Or a dynamic segment view:
<segmented:SegmentedView
ItemsSource="{Binding Persons}"
TextPropertyName="LastName"
SelectedIndex="0"
SelectedItem="{Binding SegmentSelectedItem}"
SelectedTextColor="White" TextColor="Black" SelectedBackgroundColor="Blue" DisabledColor="LightGray"
SelectionChangedCommand="{Binding SegmentSelectionChangedCommand}" />
Width of segment items
The width of a segment can be set in the following 3 ways, in reverse order of priority:
- On the
ItemsDefaultWidth
property ofSegmentedView
<segmented:SegmentedView
x:Name="TheSegmentView"
SelectedIndex="0"
SelectedTextColor="White" TextColor="Black" SelectedBackgroundColor="Blue" DisabledColor="LightGray"
SelectionChangedCommand="{Binding SegmentSelectionChangedCommand}"
SelectedItem="{Binding SegmentSelectedItem}"
ItemsDefaultWidth="150" />
- On the
ItemsWidthDefinitions
property ofSegmentedView
<segmented:SegmentedView
x:Name="TheSegmentView"
SelectedIndex="0"
SelectedTextColor="White" TextColor="Black" SelectedBackgroundColor="Blue" DisabledColor="LightGray"
SelectionChangedCommand="{Binding SegmentSelectionChangedCommand}"
SelectedItem="{Binding SegmentSelectedItem}"
ItemsWidthDefinitions="150,Auto,*,2*">
This width follow the format of a Grid's ColumnsDefinition, so it should be straightforward to use.
- Directly on the
Width
property of aSegment
<segmented:Segment Item="Item1" Width="150" />
<segmented:Segment Item="Item1" Width="Auto" />
IsSelectionRequired feature
By default, the control requires a selected item. By setting IsSelectionRequired
to False
, it won't try to constraint the SelectedIndex between 0 and the number of segments. The visual result is no segment is selected.
TLDR: set IsSelectionRequired="False"
and SelectedIndex="-1"
to visually see no selection.
Highlight color on Android
This is standard Material design on the native Android platform. Check the native doc for more info.
For quick ref:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-android34.0 is compatible. net8.0-browser was computed. net8.0-ios was computed. net8.0-ios17.2 is compatible. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.80)
-
net8.0-android34.0
- Microsoft.Maui.Controls (>= 8.0.80)
-
net8.0-ios17.2
- Microsoft.Maui.Controls (>= 8.0.80)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.6 | 415 | 8/27/2024 |
1.0.5 | 135 | 8/15/2024 |
1.0.4 | 407 | 4/15/2024 |
1.0.3 | 134 | 3/31/2024 |
1.0.2 | 129 | 3/16/2024 |
1.0.1 | 132 | 3/14/2024 |
1.0.0 | 142 | 3/5/2024 |
1.0.0-ci8141352883 | 113 | 3/4/2024 |
1.0.0-ci8139282302 | 82 | 3/4/2024 |
1.0.0-ci8113045545 | 108 | 3/1/2024 |
1.0.0-ci8016228389 | 109 | 2/23/2024 |
1.0.6: upgrade nugets.
1.0.5: Upgrade nugets.
1.0.3: add net8.0 target for unit tests
1.0.1: Upgrade nugets. Remove dependency on maui compatibility.
1.0.0: Initial release