1

在 Excel 中,当您按 Ctrl+C 时,当前单元格被一个矩形包围,虚线似乎在周围运行。关于如何在 WPF 中制作它的任何提示?

4

1 回答 1

4

您正在寻找的通常称为“行军蚂蚁边界”。WPF 已经有一些实现。

这是来自Patric Johansson 的博客来自 codeproject 的另一个

添加了来自 CodeProject 的主要代码以供将来参考:

<Window.Resources>
    <Storyboard x:Key="MarchingAnts">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" 
                           Storyboard.TargetName="rectangle" 
                           Storyboard.TargetProperty="(Shape.StrokeDashOffset)" 
                           RepeatBehavior="Forever">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000"
                           Value="10"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Window.Resources>
<Window.Triggers>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard Storyboard="{StaticResource MarchingAnts}"/>
    </EventTrigger>
</Window.Triggers>

<Grid x:Name="LayoutRoot">
    <Canvas x:Name="canvas" Background="#FF262626">
        <Rectangle Fill="#14FFFFFF" StrokeDashArray="5" 
            Stroke="#FFFFFFFF" 
            x:Name="rectangle" Width="50" Height="50" 
            StrokeDashOffset="0" StrokeThickness="1" 
            RadiusX="0" RadiusY="0"
            Canvas.Left="0" Canvas.Top="0"/>
        <TextBlock Width="Auto" Height="Auto" 
            FontFamily="Century Gothic" 
            FontSize="48" Foreground="#FF5B5B5B" 
            Text="MARCHING ANTS" TextWrapping="Wrap" 
            Canvas.Top="182" Canvas.Left="79"/>
    </Canvas>
</Grid>
于 2013-03-03T17:09:22.713 回答