且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WPF读取Checkbox.Content

更新时间:2022-06-27 02:40:14

var _tempTBL = (TextBlock) checkBox.Content; //Get handle to TextBlock
var text = _tempTBL.Text; //Read TextBlock's text

编辑:

在旁注中,您可以将所需文本直接设置为 CheckBox的内容。

On a side note, you can directly set desired text as CheckBox's content.

checkBox.Content = Hello World;

当您要访问文本时,不进行类型转换是必需的

And when you want to access the text, no type cast is needed

字符串text = checkBox.Content;