如何显示周围物体字幕样式边框在XAML C#的Windows 8(How to show Marqu

2019-10-18 22:40发布

有没有一种方法来显示物体周围字幕样式边框在WinRT中?

我看到有边框的笔触样式,

但我希望它周围像在Photoshop或油漆套索工具边框的对象移动。

此外,我需要决定什么应该是短线的两个笔划之间的间隙的颜色。

谢谢。

Answer 1:

这是你想要的,因为你想要的填充颜色:

<Page.Resources>
    <Storyboard RepeatBehavior="Forever" x:Name="Test">
        <DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" 
                Storyboard.TargetProperty="(Shape.StrokeDashOffset)" 
                Storyboard.TargetName="Marquee1">
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="3.5"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames EnableDependentAnimation="True" 
                Storyboard.TargetProperty="(Shape.StrokeDashOffset)" 
                Storyboard.TargetName="Marquee2">
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="2.5"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Page.Resources>

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Rectangle x:Name="Marquee1" Height="200" Width="200" 
               Stroke="Red" StrokeThickness="10" StrokeDashArray="0.5 2" 
               StrokeDashOffset="1" StrokeDashCap="Square" />
    <Rectangle x:Name="Marquee2" Height="200" Width="200" 
               Stroke="Green" StrokeThickness="10" StrokeDashArray="0.5 2" 
               StrokeDashOffset="0" StrokeDashCap="Square" />
    <Image Height="175" Width="175" />
</Grid>

是这样的:

祝您好运!



Answer 2:

找到一种方式来获得字幕样式边框的工作方式类似于Photoshop:

<Storyboard RepeatBehavior="Forever">
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageToDisplayBorder" Storyboard.TargetProperty="StrokeThickness">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="2"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageToDisplayBorder" Storyboard.TargetProperty="Stroke">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PaperDark}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageToDisplayBorder" Storyboard.TargetProperty="StrokeDashArray">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="3, 3"/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:0.200" Value="3, 3"/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:0.400" Value="3, 3"/>
                    </ObjectAnimationUsingKeyFrames>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ImageToDisplayBorder" Storyboard.TargetProperty="StrokeDashOffset">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="3"/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:0.200" Value="0"/>
                        <DiscreteObjectKeyFrame KeyTime="00:00:0.400" Value="3"/>
                    </ObjectAnimationUsingKeyFrames>

                </Storyboard>

我还是没有办法,虽然指定颜色峡



文章来源: How to show Marquee style border around object in xaml C# Windows 8