本文介绍了绑定到静态属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给TextBlock文本静态类的属性绑定。每当静态类变动的属性值,它应该反映这是对其他窗口或自定义控制文本块。
I want to bind a textblock text to a property of a static class. Whenever the property value of the static class changes, it should reflect to the textblock which is on the other window or custom control.
推荐答案您可以使用的 X:!静态标记扩展,但如果你不执行任何更改跟踪,这可能导致在刷新错误
You can bind to ANY property on a static class using the x:Static markup extension but if thy do not implement any change tracking, it might cause errors on the refresh!
<TextBlock Text="{Binding Source={x:Static sys:Environment.MachineName}}" />更多推荐
绑定到静态属性
发布评论