Hi
I am trying to extract my styling for a Telerik TabView into a .NET MAUI Class Library project, which I include in my MAUI application project and reference the ResourceDictionary from there. However, when I try to run the app to Android, I get the following error:
Failed to resolve assembly: 'Telerik.Maui.Controls, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
I have even tried to do this for the SDKBrowserMaui example project that shipped with the Telerik installation. The steps I followed are:
1. Add a new project in the solution. Choose ".NET MAUI Class Library".
2. Add the Telerik nuget to this new project.
3. Create a folder named Resources in the new project and add a ".NET MAUI ResourceDictionary (XAML)" file to this folder. I called it "Styles.xaml".
4. Inside the xaml file, add an assembly reference as follows:
xmlns:telerik="clr-namespace:Telerik.Maui.Controls;assembly=Telerik.Maui.Controls"
(I saw this in the maui app project, inside App.xaml)
5. Add my styles to the ResourceDictionary as follows:
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
x:Class="MauiLib1.Resources.Styles"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:telerik="clr-namespace:Telerik.Maui.Controls;assembly=Telerik.Maui.Controls">
<Style x:Key="tvhi" TargetType="telerik:TabViewHeaderItem">
<Setter Property="Padding" Value="10,5" />
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal">
<VisualState.Setters>
<Setter Property="TextColor" Value="#99ffffff" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
<VisualState Name="Disabled">
<VisualState.Setters>
<Setter Property="TextColor" Value="#b3b3b3" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
<VisualState Name="Selected">
<VisualState.Setters>
<Setter Property="TextColor" Value="White" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="BackgroundColor" Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
<Style x:Key="tvh" TargetType="telerik:TabViewHeader">
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
<Style x:Key="tvc" TargetType="telerik:TabViewContent">
<Setter Property="VerticalOptions" Value="Fill" />
</Style>
</ResourceDictionary>
6. Add a reference to the Class library project in the Maui project.
7. Inside the Maui app, in App.xaml, add the new ResourceDictionary. I should now be able to add these keys as StaticResource in my code.
However when I compile, I get the following error:
Failed to resolve assembly: 'Telerik.Maui.Controls, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' MauiLib1 C:\Program Files (x86)\Progress\Telerik UI for .NET MAUI 1.0.1\Examples\MauiLib1\Resources\Styles.xaml 1
Please can you assist, what am I doing wrong? I also tried to add the assembly reference as in my normal xaml files:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
But this gives me the error:
Cannot resolve type "http://schemas.telerik.com/2022/xaml/maui:TabViewHeaderItem". MauiLib1 C:\Program Files (x86)\Progress\Telerik UI for .NET MAUI 1.0.1\Examples\MauiLib1\Resources\Styles.xaml 8
Thank you in advance for the support.