将来自绑定源的数字显示为二进制
我需要将数字显示为二进制字符串(例如 8 => 1000)。当然,我可以使用 BitConverter 对其进行转换,并在代码隐藏文件中自行设置 TextBox 的文本。但这看起来有些难看。是否可以将文本框绑定到某个源并自动转换它?
I need to display a number as binary string (e.g. 8 => 1000). Sure I can convert it using BitConverter and set the text of my TextBox on my own in the code behind file. But this looks somewhat ugly. Is it possible to bind the TextBox to some source and convert it automatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 ValueConverter
创建一个像这样的类:
然后你可以像这样使用它(后面没有任何代码)
I would suggest to use a ValueConverter
Create a class like this:
Then you can use it like this (without any code behind)