首页 文章

Xamarin样式不起作用 - xamarin.forms

提问于
浏览
0

如果我使用样式,我的应用程序总是带有白色屏幕 . 当我调试时,我发现它不会离开线路

InitializeComponent();

这是在应用程序xaml cs

它 Build ,但永远白屏后 .

这是我的应用程序xaml:

<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="neoFly_Montana.App">
<Application.Resources>

    <!-- Application resource dictionary -->
    <ResourceDictionary>
        <Color x:key="BackButton">Black</Color>

        <Style x:Key="button" TargetType ="but">
            <Setter Property="BackgroundColor" Value="{StaticResource BackButton}"/>
        </Style>
    </ResourceDictionary>
</Application.Resources>

例外:

Xamarin.Forms.Xaml.XamlParseException:位置11:14 . 在xmlns中找不到类型但未找到http://xamarin.com/schemas/2014/forms

请帮忙

1 回答

  • 1

    没有这样的类型 but ...

    TargetType="Button" 替换 TargetType ="but" ,一切都应该正常 .

    顺便说一句,看看你的代码,它会混合出较低/较高的外壳或键名 . 我这样说是因为你的颜色的键是pascal-case,而按钮是小写的 . 您还应该使用更具体的键,而不仅仅是 button ,但我相信这只是用于示例 .

相关问题