Xaml 用于边框的Windows Phone动画

Xaml 用于边框的Windows Phone动画,xaml,windows-phone-8,Xaml,Windows Phone 8,我需要为Border元素创建某种属性“EnableBlinking”,以启用DoubleAnimation,使其具有间隔不透明度 <Border CornerRadius="5" Background="Red" EnableBlinking="True" /> 我在中找到了示例,但据我所知,这在Windows Phone中不受支持。还有一位经理。有人能给我举个例子或是好的教程吗?我不明白我需要创造风格还是新元素 谢谢您可以使用先进的XAML概念,并可以将附加属性与用户控件一起

我需要为Border元素创建某种属性“EnableBlinking”,以启用DoubleAnimation,使其具有间隔不透明度

<Border CornerRadius="5" Background="Red" EnableBlinking="True" />

我在中找到了示例,但据我所知,这在Windows Phone中不受支持。还有一位经理。有人能给我举个例子或是好的教程吗?我不明白我需要创造风格还是新元素


谢谢

您可以使用先进的XAML概念,并可以将附加属性与用户控件一起使用

创建用户控件


{
(s作为边界控件)。故事板。开始();
}));
} 
MainPage.xaml
以下是源代码:

谢谢你的例子。GetEnableBlinking和SetEnableBlinking。它是否等于公共bool enablebling{get{return(bool)GetValue(enableblingproperty);}set{SetValue(enableblingproperty,(bool)value);}}?我使用windows phone 8.0平台最欢迎David。此代码也适用于Windows phone 8.0。您可以在windows phone 8.0中使用相同的概念和代码。
<UserControl
    .................
         <UserControl.Resources>
                <Storyboard x:Name="storyBoard">
                    <DoubleAnimation Storyboard.TargetName="brd"
                             Storyboard.TargetProperty="Opacity"
                             From="0"
                             To="1"
                             RepeatBehavior="Forever"
                             AutoReverse="True"
                             Duration="0:0:0.1"/>
                </Storyboard>

            </UserControl.Resources>
            <Grid>
                <Border  x:Name="brd" CornerRadius="5" Background="Red"/>
            </Grid>
        </UserControl>


public sealed partial class BorderControl : UserControl
    {
        public BorderControl()
        {
            this.InitializeComponent();
        }

        public static bool GetEnableBlinking(DependencyObject obj)
        {
            return (bool)obj.GetValue(EnableBlinkingProperty);
        }

        public static void SetEnableBlinking(DependencyObject obj, bool value)
        {
            obj.SetValue(EnableBlinkingProperty, value);
        }

        // Using a DependencyProperty as the backing store for EnableBlinking.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty EnableBlinkingProperty =
            DependencyProperty.RegisterAttached("EnableBlinking", typeof(bool), typeof(MainPage), new PropertyMetadata(0, (s, e) =>
            {
                (s as BorderControl).storyBoard.Begin();
            }));
    } 



 MainPage.xaml
<Grid>
        <local:BorderControl EnableBlinking="true" HorizontalAlignment="Center" VerticalAlignment="Center" Height="100" Width="100"/>
    </Grid>