Add linebreak mode to the Header text, Make the Tabs fit in single screen when have multiple tabs, Chnage the color of image (PNG)

4 Answers 41 Views
TabView
Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
Mohammed Rameez asked on 02 May 2025, 10:00 AM

Hi Telerik,

I have been using RadTabView for MAUI and have used the different style but, not able to make the header text to make to next line when it has lengthy text.  and also, I need all my tabs to be visible in a single screen.

 Requirements:

1. Line break for header text.

2. Make the tabs fit the screen.

3. Change the color of image (here we are using .png).

Below is the image for your reference:

 

Thanks & Best regards,

Mohammed Rameez Raza (Rameez).

4 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 02 May 2025, 12:15 PM

Hi Rameez,

The RadTabView does not offer out-of-the-box capabilities to fill the item headers as per your requirement.

In order to get the desired effect, you need to manually calculate the width that each item should be. For example, if the whole RatTabView is 600 pixels wide, and there are 5 items in it, then each header should be 120 pixels in Width.

I've constructed a custom utils class that will do this for your custom template. I think this class will be a good starting point for you to implement the final solution. It's usage is fairly easy: local:TabViewUtils.EqualHeaderItemWidth="True"

<ControlTemplate x:Key="TabViewHeaderTemplate">
  <Grid local:TabViewUtils.EqualHeaderItemWidth="True" RowDefinitions="Auto, Auto">
    <Image Source="{TemplateBinding ImageSource}" Aspect="Center" />
    <Label Text="{TemplateBinding Text}" Grid.Row="1" LineBreakMode="WordWrap" HorizontalTextAlignment="Center" />
  </Grid>
</ControlTemplate>

 

The code I am sending contains the business logic for calculating the desired width for each item, so that the tabs can fit the screen. Using the custom template, you have direct access to the Label and Image, so you should be able to handle all desired customizations there.

Regards,
Petar Marchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Petar Marchev
Telerik team
answered on 02 May 2025, 12:26 PM

I am also attaching a couple of images of the output I get when I run the code.

 

Regards,
Petar Marchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
answered on 08 May 2025, 12:42 PM | edited on 08 May 2025, 12:42 PM

Hi Petar,

Thanks for the reply.

 

Can you also tell how exactly to change the color of the icons. I need to use the ImageSource and not the unicode.

 

Thanks,

Mohammed Rameez Raza (Rameez).

0
Didi
Telerik team
answered on 08 May 2025, 02:27 PM

Hi Mohammed,

You can add an icon and change its color using the FontImageSource. Here is an example:

<Grid>
		<telerik:RadTabView x:Name="tabView" HeaderItemStyle="{StaticResource headerstyle}">
			<telerik:RadTabView.HeaderItemTemplate>
				<ControlTemplate>
					<Grid local:TabViewUtils.EqualHeaderItemWidth="True" RowDefinitions="Auto, Auto">
						<Image Source="{TemplateBinding ImageSource}" Aspect="Center" />
						<Label Text="{TemplateBinding Text}" Grid.Row="1" LineBreakMode="WordWrap" HorizontalTextAlignment="Center" />
					</Grid>
				</ControlTemplate>
			</telerik:RadTabView.HeaderItemTemplate>
			<telerik:TabViewItem HeaderText="Som Item 1">
				<telerik:TabViewItem.ImageSource>
					<FontImageSource Glyph="&#xe804;"
									 Color="Red"
                                     FontFamily="TelerikFont"
                                    />
				</telerik:TabViewItem.ImageSource>
				<Label Text="Item 1" HorizontalOptions="Center" VerticalOptions="Center" />
			</telerik:TabViewItem>
			<telerik:TabViewItem HeaderText="Other Item 2">
				<telerik:TabViewItem.ImageSource>
					<FontImageSource Glyph="&#xe804;"
									 Color="Red"
                                     FontFamily="TelerikFont"
                                    />
				</telerik:TabViewItem.ImageSource>
				<Label Text="Item 2" HorizontalOptions="Center" VerticalOptions="Center" />
			</telerik:TabViewItem>
			<telerik:TabViewItem HeaderText="Long Item 333">
				<telerik:TabViewItem.ImageSource>
					<FontImageSource Glyph="&#xe804;"
									 Color="Red"
                                     FontFamily="TelerikFont"
                                    />
				</telerik:TabViewItem.ImageSource>
				<Label Text="Item 3" HorizontalOptions="Center" VerticalOptions="Center" />
			</telerik:TabViewItem>
		</telerik:RadTabView>
	</Grid>

Hope this helps.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
commented on 08 May 2025, 02:33 PM

Hi Didi,

 

Thanks for the reply.

The solution that you gave works for FontImageSource, I have .png image, on that i need to apply that. I need to use ImageSource directly.

Thanks.

Didi
Telerik team
commented on 08 May 2025, 02:39 PM

The png image does not have a color property. so you have to create an image with the exact look you want. 

If the image is actually an svg, how to change the color of the svg can be found here: https://medium.com/@kulashekar2025/how-to-changing-svg-image-color-dynamically-in-net-maui-6fbe4f996401 

Also you can submit question in the Microsoft forum or StackOverflow.

Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
commented on 20 May 2025, 03:39 PM | edited

I have a .ddl that contains some images, wherever we need any image we just refer the name of the image to the control's ImageSource and it picks the image directly from the ddl itself. 

It works fine for MAUI controls like image , Button, etc. but when it comes to RadTabView's ImageSource it dont show the image when specifying directly that is there in the dll. Only shows when we have the image in resource folder.

How to make it pick from ddl directly.

Thanks,

Mohammed Rameez Raza (Rameez). 

Didi
Telerik team
commented on 21 May 2025, 08:00 AM

Pelase send a sample project in which the behavior occurs, so I can research the case further. 
Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
commented on 26 May 2025, 06:03 AM

we can share the project with ddl, that is a private ddl.
Didi
Telerik team
commented on 27 May 2025, 07:26 AM

If you do not want to share the ddl in the forum, you can open a support ticket and attach a sample project to it.
Tags
TabView
Asked by
Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Petar Marchev
Telerik team
Mohammed Rameez
Top achievements
Rank 1
Iron
Iron
Iron
Didi
Telerik team
Share this question
or