Follow @RoyOsherove on Twitter

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

A simpler, conventions based DependencyProperty structure for silverlight using CustomControlBase

Fix: Requested registry access is not allowed error when creating silverlight project in visual studio 2008