Roy Osherove

View Original

Resharper template for DependencyProperty in silverlight

Here’s a much better DependencyProperty snipper for Silverlight custom controls that can be used with resharper:

        #region $PROPNAME$ Property
        public $PROPTYPE$ $PROPNAME$
        {
            get { return ($PROPTYPE$) GetValue($PROPNAME$Property); }
            set { SetValue($PROPNAME$Property,value); }
        }

        public static readonly DependencyProperty $PROPNAME$Property =
                                            DependencyProperty.Register(
            "$PROPNAME$", typeof ($PROPTYPE$), typeof ($DECLARING_TYPE$),
            new PropertyMetadata($DEF_VALUE$ , On$PROPNAME$Changed ));

        private static void On$PROPNAME$Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            $DECLARING_TYPE$ $DECLARING_TYPE_var$ = d as $DECLARING_TYPE$;
            $END$
        }
        #endregion