类型System.Drawing.Font和.Bitmap的DependencyProperties的默认值

时间:2012-01-13 08:41:27

标签: c# dependency-properties

这是我的代码:

public class CustomWidget
{
    public System.Drawing.Color Value
    {
        get { return (System.Drawing.Color)GetValue(ValueProperty); }
        set { SetValue(ValueProperty, value); }
    }
    public static readonly DependencyProperty ValueProperty =
        DependencyProperty.Register("Value", typeof(System.Drawing.Color), typeof(Color), new UIPropertyMetadata(0));

    public System.Drawing.Font Valuee
    {
        get { return (System.Drawing.Font)GetValue(ValueeProperty); }
        set { SetValue(ValueeProperty, value); }
    }
    public static readonly DependencyProperty ValueeProperty =
        DependencyProperty.Register("Valuee", typeof(System.Drawing.Font), typeof(Font), new UIPropertyMetadata(0));
}

对于Font,我可以设置一个默认的Font,我认为没有其他方式,但是Bitmap呢?我绝对必须在我的项目中获得一个将被引用为默认值的位图吗?

1 个答案:

答案 0 :(得分:3)

不,您只需使用null