首页 > 解决方案 > 如何在 Uno 平台中将 RadialGradientBrush 与 Storyboard 一起使用

问题描述

我想在 Uno 平台中将 RadialGradientBrush 与 Storyboard 一起使用。

我用“Microsoft.UI.Xaml.Media”来显示RadialGradientBrush,显示没问题。

但是当我将 RadialGradientBrush 与 Storyboard 一起使用时,Storyboard 的TargetProperty将显示“无法解析 TargetProperty ”。

谁能帮我解决这个问题,tks...

主页.xml:

<Page
    x:Class="App7.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App7"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    
    xmlns:media="using:Microsoft.UI.Xaml.Media"
    mc:Ignorable="d">
    <Page.Resources>
        <Storyboard x:Name="Storyboard1">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(media:RadialGradientBrush.GradientStops)[1].(GradientStop.Offset)" Storyboard.TargetName="path1">
                <EasingDoubleKeyFrame KeyTime="0:0:8" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:11.1" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Page.Resources>

    <Grid x:Name="LayoutRoot" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="1500" Height="1000">
        <Grid Margin="181,120,679,590" ScrollViewer.VerticalScrollBarVisibility="Disabled" Width="640" Height="290">
            <Path x:Name="path1" Data="M20.5,0.5 L20.5,131.1568 L19.245193,130.66107 C12.863921,128.07494 6.880846,125.19048 1.3586025,122.0434 L0.5,121.54227 L0.5,10.114529 L1.3586025,9.6134071 C6.880846,6.4663239 12.863921,3.5818634 19.245193,0.99572372 z" HorizontalAlignment="Left" Margin="61,62.172,0,86.172" Stretch="Fill" Stroke="Black" UseLayoutRounding="False" Width="21">
                <Path.Fill>
                    <media:RadialGradientBrush x:Name="radial">
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="White" Offset="0.842"/>
                    </media:RadialGradientBrush>
                </Path.Fill>
            </Path>
        </Grid>
    </Grid>
</Page>

Storyboard1.Begin(); 当我在 MainPage.xaml.cs 中调用时出现错误消息 :

   System.Exception: 'No installed components were detected.

Cannot resolve TargetProperty (Shape.Fill).(media:RadialGradientBrush.GradientStops)[1].(GradientStop.Offset) on specified object.'

标签: uwpwin-universal-appuno-platform

解决方案


推荐阅读