绑定到静态属性

编程入门 行业动态 更新时间:2024-10-23 03:23:57
本文介绍了绑定到静态属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想给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}}" />

更多推荐

绑定到静态属性

本文发布于:2023-11-12 12:31:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581506.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   静态   属性

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!