简体   繁体   English

我们可以使用 Xamarin.Forms for UWP 获得流畅的设计吗?

[英]Can we get fluid design with Xamarin.Forms for UWP?

Can we get the fluid design in Windows 10 UWP app with Xamarin.Forms?我们可以使用 Xamarin.Forms 在 Windows 10 UWP 应用中获得流畅的设计吗? https://docs.microsoft.com/en-us/windows/uwp/style/acrylic https://docs.microsoft.com/en-us/windows/uwp/style/acrylic

Jason is technically right since the feature isn't publically released yet. Jason 在技术上是正确的,因为该功能尚未公开发布。 However, you should be able to try it already if you're in the Windows Insider Preview program.但是,如果您在 Windows Insider Preview 计划中,您应该已经可以尝试了。 This is what you need:这是你需要的:

  1. Latest version of Visual Studio (2017, 15.3)最新版本的 Visual Studio (2017, 15.3)
  2. Latest Windows 10 Insider Preview SDK (probably 16267)最新的 Windows 10 Insider Preview SDK(可能是 16267)
  3. Latest version of the .NET UWP NuGet Package .NET UWP NuGet 包的最新版本

You can check that you have the correct version if Windows.UI.Xaml.Media.AcrylicBrush is accessible.如果Windows.UI.Xaml.Media.AcrylicBrush可访问,您可以检查您的版本是否正确。


Using with Xamarin.Forms: I haven't tried this myself but technically it should be possible.与 Xamarin.Forms 一起使用:我自己没有尝试过,但从技术上讲应该是可能的。 You'll need to roll out a custom renderer for the UWP platform where you define the Acrylic brush and add it to a control (Grid in this example).您需要为 UWP 平台推出自定义渲染器,您可以在其中定义 Acrylic 画笔并将其添加到控件(在此示例中为 Grid)。 You also need to make sure to check that the XamlCompositionBrushBase is present and have a fallback for the case where it's not.您还需要确保检查XamlCompositionBrushBase是否存在,并在XamlCompositionBrushBase存在的情况下进行回退。

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 = Color.FromArgb(255, 202, 24, 37);
    myBrush.FallbackColor = Color.FromArgb(255, 202, 24, 37);
    myBrush.TintOpacity = 0.6;

    grid.Fill = myBrush;
}
else
{ 
    SolidColorBrush myBrush = new SolidColorBrush(Color.FromArgb(255, 202, 24, 37));

    grid.Fill = myBrush;
}

This code is taken straight from the article you linked to but it should work as is in the custom renderer.此代码直接取自您链接到的文章,但它应该在自定义渲染器中正常工作。

Please notice, that even if you get it to work, there might be major changes to the API and you'll have to rework your solution again and again.请注意,即使您可以使用它,API 也可能会发生重大变化,您将不得不一次又一次地重新设计您的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM