【问题标题】:Xamarin styles doesn't work - xamarin.formsXamarin 样式不起作用 - xamarin.forms
【发布时间】:2018-01-02 06:05:12
【问题描述】:

如果我使用样式,我的应用程序总是带有白屏。 当我调试时我发现它并没有离开这条线

InitializeComponent();

在应用程序 xaml cs 中

它可以构建,但在永远出现白屏之后。

这是我的应用 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发生

请帮忙

【问题讨论】:

    标签: xaml xamarin.forms styles


    【解决方案1】:

    没有这种类型but...

    TargetType ="but" 替换为TargetType="Button",一切正常。

    顺便说一句,看看你的代码,采用严格的命名规则是一个好习惯,这样你就不会混淆小写/大写或键名。我这样说是因为您的颜色键是帕斯卡大小写,而按钮是小写。 您还应该使用更具体的键,而不仅仅是 button,但我相信这只是示例。

    【讨论】:

      猜你喜欢
      • 2019-04-29
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-22
      • 2014-06-05
      相关资源
      最近更新 更多