我正在编写一个函数,它将采用Control Ctrl
作为Arguement
并修改它的Control.Content
。 是否有任何方法获取并设置Content
任何Control
??如何获取WPF中任何控件的“内容”?
代码:
void RemoveHotKey(Control Ctrl, int KeyIndex)
{
if (Ctrl.Content.ToString().Substring(KeyIndex, 1) == "_") // System.Windows.Controls.Control does not contain a definition for 'Content'
{
Ctrl.Content = Ctrl.Content.ToString().Remove(KeyIndex, 1); // System.Windows.Controls.Control does not contain a definition for 'Content'
}
}
你为什么要使用控制类的说法,而不是ContentControl中类参数? – mtijn