Xamarin Global Syles更新后无法正常工作

时间:2018-08-06 14:44:33

标签: c# android visual-studio xamarin

我认为在VS更新之后,Xamarin全局样式不再起作用。 它显示了标准按钮,没有样式,但是如果我重命名样式,则会出现错误。因此,它读取的样式可能无法正确呈现。

我的配置是:

App.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="MyApp.App">
    <Application.Resources>

        <!-- Application resource dictionary -->
        <ResourceDictionary>
            <Style x:Key="bigButton" TargetType="Button">
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="VerticalOptions" Value="CenterAndExpand" />
                <Setter Property="BorderRadius" Value="5" />
                <Setter Property="BorderWidth" Value="5" />
                <Setter Property="WidthRequest" Value="200" />
                <Setter Property="HeightRequest" Value="70" />
                <Setter Property="TextColor" Value="#00536c" />
            </Style>
            <Style x:Key="smallButton" TargetType="Button">
                <Setter Property="HorizontalOptions" Value="Center" />
                <Setter Property="VerticalOptions" Value="CenterAndExpand" />
                <Setter Property="BorderRadius" Value="3" />
                <Setter Property="BorderWidth" Value="3" />
                <Setter Property="WidthRequest" Value="200" />
                <Setter Property="HeightRequest" Value="40" />
                <Setter Property="TextColor" Value="#00536c" />
            </Style>
            <Style x:Key="cancelButton" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Red" />
                <Setter Property="TextColor" Value="White" />
            </Style>
            <Style x:Key="confirmButton" TargetType="Button">
                <Setter Property="BackgroundColor" Value="Green" />
                <Setter Property="TextColor" Value="White" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>

App.xaml.cs

using MyApp.Interfaces;
using MyApp.Layouts;
using Xamarin.Forms;

namespace MyApp
{
    public partial class App : Application
    {
        public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new LoaderPage(LoaderPageFunction.CheckLogin));
        }

        protected override void OnStart()
        {
            // Handle when your app starts
            DependencyService.Get<ISyncHandler>().Start();
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }
    }
}

在xaml屏幕中:

<Button Grid.Row="1" Grid.Column="0" x:Name="CancelButton" Text="Annulla" Clicked="CancelButton_Clicked" BackgroundColor="Red" Style="{StaticResource cancelButton}" WidthRequest="1"></Button>
            <Button Grid.Row="1" Grid.Column="1" x:Name="ConfirmButton" Text="Conferma" Clicked="ConfirmButton_Clicked" Style="{StaticResource confirmButton}" WidthRequest="1"></Button>

此配置运行正常,但现在我无法弄清为什么它不再运行。

版本: VS 2017年15.7.6 Xamarin 4.10.10.2

0 个答案:

没有答案