繁体   English   中英

在 uwp 中使用依赖属性时,如何区分默认值和分配值

[英]When using a dependency property in uwp, how can I tell the difference between default value and assigned value

在 uwp 中使用依赖属性时,如何区分默认值和分配值

我已经在 wpf 的 dependencypropertyhelper 中使用了这种情况,但这不可用 uwp。

任何人都可以在 uwp 中分享解决方案吗?

您可以将ReadValue方法返回的值与DependencyProperty.UnsetValue进行比较,例如:

TextBlock textBlock = new TextBlock();
if (textBlock.ReadLocalValue(TextBlock.TextProperty) ==  DependencyProperty.UnsetValue)
{
    //property not set...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM