Why does BasedOn?

Amelia Middleton 0 Reputation points
2024-08-17T19:49:15.35+00:00

Severity Code Description Project File Line Suppression State

Error (active) XFC0009 No property, BindableProperty, or event found for "BasedOn", or mismatching type between value and property. TipCalculator (net8.0-windows10.0.19041.0) C:\Users\ameli\source\repos\mslearn-dotnetmaui-use-shared-resources\exercise3\TipCalculator\StandardTipPage.xaml 15

I am referring to tutorial:
https://learn.microsoft.com/en-us/training/modules/use-shared-resources/7-exercise-create-and-apply-a-style

This question is related to the following Learning Module

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,578 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
814 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 43,921 Reputation points Microsoft Vendor
    2024-08-19T02:55:09.5533333+00:00

    After testing, I tested the BasedOn property with the following code and this issue did not occur.

    
    <?xml version="1.0" encoding="utf-8" ?>
    
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    
                 x:Class="MauiApp6.MainPage">
    
    <ContentPage.Resources>
    
    	<Style x:Key="baseLabelStyle" TargetType="Label">
    
    	<Setter Property="FontSize" Value="Caption" />
    
    	</Style>
    
    	<Style x:Key="infoLabelStyle" BasedOn="{StaticResource baseLabelStyle}" TargetType="Label">
    
    	<Setter Property="FontAttributes" Value="Bold" />
    
    	</Style>
    
    </ContentPage.Resources>
    
    <ScrollView>
    
    	<Label Text="test" Style="{StaticResource infoLabelStyle}"/>
    
    </ScrollView>
    
     
    
    </ContentPage>
    
    

    According to MauiMaui API documentation, Style.BasedOn Property is a basic property. Therefore, this issue is more of a namespace issue. Does your Maui project include the Nuget Package for Microsoft.Maui.Controls? If you update it to the latest version, will this issue still occur?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.