设置你的风格了作为dynamicresources这里看到https://developer.xamarin.com/guides/xamarin-forms/user-interface/styles/dynamic/
我只有2个主题,所以我让他们在XAML在主题更改事件指定
<ResourceDictionary>
<Color x:Key="Primary">#337ab7</Color>
<Color x:Key="Accent">#96d1ff</Color>
<Color x:Key="BackgroundColor">#C0C0C0</Color>
<Color x:Key="TextColor">White</Color>
<!-- Buttons -->
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="BorderRadius" Value="4" />
<Setter Property="FontSize" Value="48" />
<Setter Property="FontAttributes" Value="Bold" ></Setter>
<Setter Property="HeightRequest">
<Setter.Value>
<OnPlatform x:TypeArguments="x:Double" iOS="80" Android="80" />
</Setter.Value>
</Setter>
<Setter Property="WidthRequest">
<Setter.Value>
<OnPlatform x:TypeArguments="x:Double" iOS="150" Android="150" />
</Setter.Value>
</Setter>
</Style>
<Style x:Key="btnPrimary" TargetType="Button" BasedOn="{StaticResource buttonStyle}">
<Setter Property="TextColor" Value="{DynamicResource TextColor}" />
<Setter Property="BackgroundColor" Value="{DynamicResource Primary}" />
</Style>
<!--Light Theme-->
<Color x:Key="Primary-Light">#2196F3</Color>
<Color x:Key="BackgroundColor-Light">#FAFAFA</Color>
<Color x:Key="TextColor-Light">White</Color>
<!--Dark Theme-->
<Color x:Key="Primary-Dark">#1976D2</Color>
<Color x:Key="BackgroundColor-Dark">#C0C0C0</Color>
<Color x:Key="TextColor-Dark">Black</Color>
</ResourceDictionary>
所以你可以更改指定的颜色
Resources ["Primary"] = Resources ["Primary-Dark"];
感谢您的答复。已经看到了它,但不知道它将如何工作。假设我有2个客户端ClientA和ClientB,它们都共享相同的可移植类库以及所有视图。它将如何工作。任何示例? – developer9969
增加了一个例子 –
非常感谢你添加一个例子,我将尝试把它放在一起看看它是否适用于我。但是你可以让资源字典来自2个不同的assemblies.EG ClientA.Styles和ClientB。样式,然后以某种方式便携式可以实现一个或另一个。希望它是有道理的,我试图实现。 “每个客户端能够运行不同风格的相同应用程序 – developer9969