2
XAML 및 Xamrin을 배우고 있습니다. 정적 스타일이 작동하는 방법을 배우려고합니다. 이미 나는 스타일 '키'때문에이 오류가 왜Xamarin Forms 빌드 오류 - 키에 StaticResource가 없습니다.
[ERROR] FATAL UNHANDLED EXCEPTION: Xamarin.Forms.Xaml.XamlParseException: Position 25:58. StaticResource not found for key baseStyle
이해가 안된다
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Styles"
x:Class="Styles.MainPage">
<ContentPage.Resources>
<ResourceDictionary>
<Style x:key="buttonStyle" TargetType="Button">
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="TextColor" Value="Red"/>
<Setter Property="FontSize" Value="Small"/>
</Style>
<Style TargetType="Label">
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="TextColor" Value="Blue"/>
<Setter Property="FontSize" Value="20"/>
</Style>
<Style x:key="baseStyle" TargetType="View">
<Setter Property="HorizontalOptions" Value="Center"/>
<Setter Property="VerticalOptions" Value="Center" />
</Style>
<Style x:key="entryStyle" TargetType="Entry" BasedOn="{StaticResource baseStyle}">
<Setter Property="TextColor" Value="Green"/>
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="20">
<Label Text="This is label 1 using implicit style"/>
<Label Text="This is label 2"/>
<Button
Text="Not using the button style"
BorderWidth="2"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="200"/>
<Button Style="{StaticResource buttonStyle}"
Text="Using explicit style"
BorderWidth="2"
WidthRequest="200"/>
<Entry Style="{StaticResource entryStyle}" Placeholder="This enty uses an inherited style"/>
<Button Style="{StaticResource buttonStyle}"
Text="Using explicit style"
BorderWidth="2"
WidthRequest="200"/>
</StackLayout>
</ContentPage.Content>
</ContentPage>
컴파일이 잘 작동하지만 실행할 때, 나는이 예외가 : 여기 내 XAML 코드입니다 이전 행에 정의되어 있습니다. 어떤 도움이라도 대단히 감사합니다.
AAAaaarrr. 그게 고마워! – jacDeveloper