Xamarin Forms是否支持基础应用程序资源?

时间:2016-03-03 01:53:07

标签: xaml xamarin.forms

我有一个应用程序,将为不同的租户(主要是服务层和轻量级UI更改)轻松定制,所以我设计了一个核心项目与基础应用程序类,租户项目必须继承。所述基础应用程序类具有关联的应用程序XAML以及一些隐式应用程序范围的样式,但似乎应用程序不会选择它们,因为控件使用完全本机样式呈现。

它真的不受支持,或者我在这里做错了什么?

这是XAML

<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  xmlns:branding="clr-namespace:AT.UI.Common.Branding;assembly=AT.UI.Common"
    x:Class="AT.UI.Common.BaseATApplication">

  <!-- TODO: Find out how to make this work for subclasses -->
  <Application.Resources>
    <ResourceDictionary>
        <Style TargetType="Button">
          <Setter Property="BackgroundColor" Value="{x:Static branding:UIBranding.StandbyButtonBackgroundColor}" />
          <Setter Property="TextColor" Value="{x:Static branding:UIBranding.ButtonForegroundColor}" />
        </Style>
      </ResourceDictionary>
  </Application.Resources>
</Application>

BaseATApplication的构造函数具有所需的InitializeComponent()调用。

1 个答案:

答案 0 :(得分:0)

我认为他们需要明确引用

<Style x:Key="ButtonStyle" TargetType="Button">
          <Setter Property="BackgroundColor" Value="{x:Static branding:UIBranding.StandbyButtonBackgroundColor}" />
          <Setter Property="TextColor" Value="{x:Static branding:UIBranding.ButtonForegroundColor}" />
</Style>

<Button Style="{StaticResource ButtonStyle}" />
相关问题