gpt4 book ai didi

c# - Xamarin.Forms 问题中的流畅设计

转载 作者:行者123 更新时间:2023-11-30 12:38:16 24 4
gpt4 key购买 nike

我正在尝试让 Fluent Design 在我的 Xamarin.Forms UWP 应用程序上运行。我尝试了使用渲染器、覆盖样式的不同方法,但都不起作用。

Acrylic 画笔总是退回到 FallbackColor。

设置:

目标版本:Windows 10 (1803)
最低版本:Windows 10 Fall Creators Update(16299)。

我也在检查

可用的 Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.AcrylicBrush")。

使用任何预定义的 Acrylic 画笔会导致“无法找到具有名称/ key SystemControlChromeLowAcrylicWindowBrush 的资源”。

AcrylicBrush 和 Splitview 样式:

<media:AcrylicBrush x:Key="HostBackdropBrush"
BackgroundSource="HostBackdrop"
TintColor="White"
TintOpacity="0.4"
FallbackColor="WhiteSmoke" />


<Style TargetType="SplitView">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="OpenPaneLength" Value="{ThemeResource SplitViewOpenPaneThemeLength}"/>
<Setter Property="CompactPaneLength" Value="{ThemeResource SplitViewCompactPaneThemeLength}"/>
<Setter Property="PaneBackground" Value="{StaticResource HostBackdropBrush}"/>
</Style>

自定义渲染器:

[assembly: ExportRenderer(typeof(MasterPage), typeof(MasterPageRenderer))]
namespace MasterDetailPageNavigation.UWP
{
class MasterPageRenderer : PageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || Element == null)
{
return;
}

try
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.Xaml.Media.XamlCompositionBrushBase"))
{
Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
myBrush.TintColor = Windows.UI.Color.FromArgb(255, 200, 200, 200);
myBrush.TintOpacity = 0.2;

Background = myBrush;
}
else
{
SolidColorBrush myBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 240, 240, 240));

Background = myBrush;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}
}

protected override Windows.Foundation.Size ArrangeOverride(Windows.Foundation.Size finalSize)
{
return base.ArrangeOverride(finalSize);
}

}
}

最佳答案

请看Link

这应该可以解决您的问题。您可以通过将 ThemeResources.xaml 添加到项目资源来解决此问题。

关于c# - Xamarin.Forms 问题中的流畅设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54362810/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com