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

+50
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

+14
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

+15
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

+15
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

+10
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

+43
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

+12
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

+26
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+
}
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>
+11
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Android.App;
2+
using Android.Runtime;
3+
4+
namespace TabView
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#512BD4</color>
4+
<color name="colorPrimaryDark">#2B0B98</color>
5+
<color name="colorAccent">#2B0B98</color>
6+
</resources>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Foundation;
2+
3+
namespace TabView
4+
{
5+
[Register("AppDelegate")]
6+
public class AppDelegate : MauiUIApplicationDelegate
7+
{
8+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
5+
<dict>
6+
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
7+
<key>com.apple.security.app-sandbox</key>
8+
<true/>
9+
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
10+
<key>com.apple.security.network.client</key>
11+
<true/>
12+
</dict>
13+
</plist>
14+
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<!-- The Mac App Store requires you specify if the app uses encryption. -->
6+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
7+
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
8+
<!-- Please indicate <true/> or <false/> here. -->
9+
10+
<!-- Specify the category for your app here. -->
11+
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
12+
<!-- <key>LSApplicationCategoryType</key> -->
13+
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
14+
<key>UIDeviceFamily</key>
15+
<array>
16+
<integer>2</integer>
17+
</array>
18+
<key>UIRequiredDeviceCapabilities</key>
19+
<array>
20+
<string>arm64</string>
21+
</array>
22+
<key>UISupportedInterfaceOrientations</key>
23+
<array>
24+
<string>UIInterfaceOrientationPortrait</string>
25+
<string>UIInterfaceOrientationLandscapeLeft</string>
26+
<string>UIInterfaceOrientationLandscapeRight</string>
27+
</array>
28+
<key>UISupportedInterfaceOrientations~ipad</key>
29+
<array>
30+
<string>UIInterfaceOrientationPortrait</string>
31+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
32+
<string>UIInterfaceOrientationLandscapeLeft</string>
33+
<string>UIInterfaceOrientationLandscapeRight</string>
34+
</array>
35+
<key>XSAppIconAssets</key>
36+
<string>Assets.xcassets/appicon.appiconset</string>
37+
</dict>
38+
</plist>
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using ObjCRuntime;
2+
using UIKit;
3+
4+
namespace TabView
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+
}

TabView/Platforms/Tizen/Main.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using Microsoft.Maui;
3+
using Microsoft.Maui.Hosting;
4+
5+
namespace TabView
6+
{
7+
internal 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+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="9" xmlns="http://tizen.org/ns/packages">
3+
<profile name="common" />
4+
<ui-application appid="maui-application-id-placeholder" exec="TabView.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
5+
<label>maui-application-title-placeholder</label>
6+
<icon>maui-appicon-placeholder</icon>
7+
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
8+
</ui-application>
9+
<shortcut-list />
10+
<privileges>
11+
<privilege>http://tizen.org/privilege/internet</privilege>
12+
</privileges>
13+
<dependencies />
14+
<provides-appdefined-privileges />
15+
</manifest>

TabView/Platforms/Windows/App.xaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<maui:MauiWinUIApplication
2+
x:Class="TabView.WinUI.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:maui="using:Microsoft.Maui"
6+
xmlns:local="using:TabView.WinUI">
7+
8+
</maui:MauiWinUIApplication>

TabView/Platforms/Windows/App.xaml.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 TabView.WinUI
7+
{
8+
/// <summary>
9+
/// Provides application-specific behavior to supplement the default Application class.
10+
/// </summary>
11+
public partial class App : MauiWinUIApplication
12+
{
13+
/// <summary>
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+
/// </summary>
17+
public App()
18+
{
19+
this.InitializeComponent();
20+
}
21+
22+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23+
}
24+
25+
}

0 commit comments

Comments
 (0)