System.Drawing.Font 和 .Bitmap 类型的 DependencyProperties 的默认值
这是我的代码:
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));
}
对于字体,我可以设置默认字体,我认为没有其他方法,但是位图呢?我绝对必须在我的项目中获取一个将被引用为默认值的位图吗?
Here is the code I have :
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));
}
For the Font, I can set a default Font, there is not other way I think, but what about the Bitmap ? Do I absolutelyu have to get a Bitmap in my project that will be referenced for the default value ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您可以简单地使用
null
。No, you can simply use
null
.