With the Telerik Silverlight controls, how can I cast a RadMaskedTextBox as a TextBox

冷暖自知 提交于 2019-12-12 06:58:17

问题


I am trying to determine if a Telerik RadMaskedTextBox allows multiline input.

I the debugger, I was able to find and check the .AcceptsReturn property of the underlying textbox, using:

((System.Windows.Controls.TextBox)(((Telerik.Windows.Controls.RadMaskedTextBox)(this)).textBox)).AcceptsReturn;

However, when I paste that into my C# code, the compiler complains that RadMaskedTextBox cannot be cast as a TextBox

A little weird, since the Debugger allows it.

The debugger also allows:

((System.Windows.Controls.TextBox)(((Telerik.Windows.Controls.RadMaskedTextBox)(this)).textBox)).TextWrapping

this the compiler complains about

Any ideas?


回答1:


I tried to do this in the past (sorry can't remember the exact way to go about this) but I had to traverse the object and find the textbox control. If I can find the project where I did it I will update my answer.




回答2:


From the Telerik Support Forum:

The underlying TextBox is of type ExtendedTextBox. You can access it like so:

var innerBox = this.masktextBox.ChildrenOfType<Telerik.Windows.Controls.MaskedTextBox.ExtendedTextBox>().FirstOrDefault();


来源:https://stackoverflow.com/questions/6085317/with-the-telerik-silverlight-controls-how-can-i-cast-a-radmaskedtextbox-as-a-te

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!