Skip to content

Commit 5682fd8

Browse files
Merge pull request #1 from SyncfusionExamples/ImageSizeForTabview
Added sample for ImageSize feature.
2 parents 81c7215 + d5a048d commit 5682fd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+9124
-0
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
11
# How-to-customize-the-Image-size-in-.NET-MAUI-TabView
22
This repository contains a sample explaining how to Customize the Image size in .NET MAUI TabView.
3+
4+
### ImageSize support in .NET MAUI TabView
5+
6+
The `ImageSize` property allows you to customize the size of images in the TabView control, enhancing its visual appeal and ensuring consistency.
7+
8+
The following code example illustrate how to Customize ImageSize in SfTabView.
9+
10+
### XAML
11+
12+
```
13+
<Grid VerticalOptions="FillAndExpand">
14+
<tabView:SfTabView x:Name="tabview" TabBarHeight="100">
15+
<tabView:SfTabItem ImageSize="50" Header="Jackson" ImageSource="jackson.png">
16+
<StackLayout Padding="10">
17+
<Label Text="Welcome, Jackson!"
18+
FontSize="18"
19+
HorizontalOptions="Center" />
20+
<Label Text="Here is your profile information."
21+
FontSize="14"
22+
HorizontalOptions="Center" />
23+
</StackLayout>
24+
</tabView:SfTabItem>
25+
26+
<tabView:SfTabItem ImageSize="50" Header="Liam" ImageSource="liam.png">
27+
<StackLayout Padding="10">
28+
<Label Text="Welcome, Liam!"
29+
FontSize="18"
30+
HorizontalOptions="Center" />
31+
<Label Text="Here is your profile information."
32+
FontSize="14"
33+
HorizontalOptions="Center" />
34+
</StackLayout>
35+
</tabView:SfTabItem>
36+
</tabView:SfTabView>
37+
</Grid>
38+
```
39+
40+
### C#
41+
42+
```
43+
var tabView = new SfTabView();
44+
var tabItems = new TabItemCollection
45+
{
46+
new SfTabItem()
47+
{
48+
ImageSize = 50,
49+
}
50+
};
51+
tabView.Items = tabItems;
52+
```

TabView/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:TabView"
5+
x:Class="TabView.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

TabView/App.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace TabView
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new AppShell());
13+
}
14+
}
15+
}

TabView/AppShell.xaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="TabView.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:TabView"
7+
Shell.FlyoutBehavior="Flyout"
8+
Title="TabView">
9+
10+
<ShellContent
11+
Title="Home"
12+
ContentTemplate="{DataTemplate local:MainPage}"
13+
Route="MainPage" />
14+
15+
</Shell>

TabView/AppShell.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TabView
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}

TabView/MainPage.xaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="TabView.MainPage"
5+
xmlns:tabView="clr-namespace:Syncfusion.Maui.TabView;assembly=Syncfusion.Maui.TabView">
6+
7+
<Grid VerticalOptions="FillAndExpand">
8+
<tabView:SfTabView x:Name="tabview" TabBarHeight="100">
9+
<tabView:SfTabItem ImageSize="50" Header="Jackson" ImageSource="jackson.png">
10+
<StackLayout Padding="10">
11+
<Label Text="Welcome, Jackson!"
12+
FontSize="18"
13+
HorizontalOptions="Center" />
14+
<Label Text="Here is your profile information."
15+
FontSize="14"
16+
HorizontalOptions="Center" />
17+
</StackLayout>
18+
</tabView:SfTabItem>
19+
20+
<tabView:SfTabItem ImageSize="50" Header="Liam" ImageSource="liam.png">
21+
<StackLayout Padding="10">
22+
<Label Text="Welcome, Liam!"
23+
FontSize="18"
24+
HorizontalOptions="Center" />
25+
<Label Text="Here is your profile information."
26+
FontSize="14"
27+
HorizontalOptions="Center" />
28+
</StackLayout>
29+
</tabView:SfTabItem>
30+
31+
<tabView:SfTabItem ImageSize="50" Header="Lita" ImageSource="lita.png">
32+
<StackLayout Padding="10">
33+
<Label Text="Welcome, Lita!"
34+
FontSize="18"
35+
HorizontalOptions="Center" />
36+
<Label Text="Here is your profile information."
37+
FontSize="14"
38+
HorizontalOptions="Center" />
39+
</StackLayout>
40+
</tabView:SfTabItem>
41+
</tabView:SfTabView>
42+
</Grid>
43+
</ContentPage>

TabView/MainPage.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace TabView
2+
{
3+
public partial class MainPage : ContentPage
4+
{
5+
public MainPage()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
}
11+
12+
}

TabView/MauiProgram.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
namespace TabView
4+
{
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureSyncfusionCore()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
23+
return builder.Build();
24+
}
25+
}
26+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
4+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
</manifest>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Android.App;
2+
using Android.Content.PM;
3+
using Android.OS;
4+
5+
namespace TabView
6+
{
7+
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
8+
public class MainActivity : MauiAppCompatActivity
9+
{
10+
}
11+
}

0 commit comments

Comments
 (0)