Hi, I am trying to create DependencyProperties that have a nice drop down code completion when using them in the XAML-editor in Visual Studio.
Many default SilverLight framework properties have such completion, e.g., Background
or BorderBrush
. Also, Boolean
Properties show the True
/False
selection in the XAML-editor. The same holds true for DependencyProperties, such as Canvas.Top
and Canvas.Left
, etc.
I tried to define my own DependencyProperties of type Color
or Boolean
, since i believed that default types like Color, Brush, and Boolean might get completion for free. This did not happen.
I believe that i have to define some annotations for my properties, but did not find an example since the Silverlight SDK only shows the public API in Visual Studio, and not the internals.
Do you have an idea, how to get code completed Properties?
Update: Here is an example of what I am trying to do in SilverLigth 3 (!) I just talked to a colleage, and he believes that the problem is related to Silverlight 3 and the old non-VS2010-XAML-editor in VS 2008.
XAML:
<Grid x:Name="LayoutRoot">
<Border test:PropTest.Test="Blue">
<TextBlock Text="123"/>
</Border>
</Grid>
Code behind
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 compileable/runnable, but I want to write an API using DependencyProperties
and not an application and thus I want code completion for my API. :)