Silverlight / Blend - How to create FontSize dependency property with dropdown list
In my custom behavior I have created the following dependency property:
public double FontSize
{
get { return (double)GetValue(FontSizeProperty); }
开发者_StackOverflow set { SetValue(FontSizeProperty, value); }
}
public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(
"FontSize",
typeof (double),
typeof (CustomBehavior),
new PropertyMetadata(11, null));
- How to bind value, 'couse In Blend binding button is disabled.
- How to show dropdown list of standart font sizes like for Textblock in Text category
I don't know if this helps or if you already found the answer but I here it goes for ...
Part 2 of your question:
You first declare an enum of items:
public enum DDItems
{
Default = 0,
Item1 = 1,
Item2 = 2,
Item3 = 3,
Item4 = 4,
Item5 = 5
}
And then you have the dependency property like this:
public DDItems TextSearchModeABC
{
get
{
return (DDItems)GetValue(MyItemProperty);
}
set
{
SetValue(MyItemProperty, value);
}
}
public static readonly DependencyProperty MyItemProperty =
DependencyProperty.Register("MyItemProperty", typeof(DDItems), typeof(MyControlType), new PropertyMetadata(null));
Hope this helps.
精彩评论