I am trying to create DependencyProperties that have nice dropdown code when using it in a XAML editor in Visual Studio.
Many SilverLight platform properties by default have this completion, for example, Backgroundor BorderBrush. In addition, BooleanProperties show the True/ option Falsein the XAML editor. The same is true for DependencyProperties, for example Canvas.Top, and Canvas.Leftetc.
I tried defining my own DependencyProperties of type Coloror Boolean, since I figured that default types like Color, Brush and Boolean could get terminated for free. That did not happen.
I believe that I need to define some annotations for my properties, but did not find an example, since the Silverlight SDK only shows the open API in Visual Studio, not the internals.
Do you have an idea how to get code completed by Properties?
Update: Here is an example of what I'm trying to do in SilverLigth 3 (!) I just talked with a colleague and he believes that the problem is related to Silverlight 3 and the old VS2010-XAML editor in VS 2008.
XAML:
<Grid x:Name="LayoutRoot">
<Border test:PropTest.Test="Blue">
<TextBlock Text="123"/>
</Border>
</Grid>
Code for
namespace PropTest{
public class PropTest : DependencyObject {
public static readonly DependencyProperty TestProperty = DependencyProperty.RegisterAttached(
"Test", typeof(Color), typeof(PropTest), new PropertyMetadata(Colors.Red));
public static void SetTest(DependencyObject obj, Color color){
(obj as Border).Background = new SolidColorBrush(color);
}
public static Color GetTest(DependencyObject obj){
return Colors.Red;
}
}
}
This example is compiled / executable, but I want to write an API using DependencyProperties, rather than an application, and thus I want to complete the code for my API. :)