有没有一种方法可以使用WPF xaml代码创建数字文本框? [英] Is there a way to create Numberic Textboxes using WPF xaml code?
问题描述
我是WPF的新手。我需要创建仅接受数字的文本框。不接受任何特殊字符,字母。
I am new to WPF. I need to create textboxes which is only accept digits. Not accepted any special characters, letters .
重要的是,代码仅是xaml而不是c#。
我用Google搜索了很多网站,但是我只得到了使用c#的代码。但是我想要XAML代码。因为我将它像样式一样包含在控件中。
I googled lot of websites , but i only get the code used c#. But i want in XAML code. Because i enclosed it like styles in controls.
有什么方法可以做到这一点?如果不可能,为什么?
Is there any way to do this? And if it is not possible Why?
推荐答案
否,这不可能,因为XAML是标记语言。它不支持区分数字和其他类型的字符。
No, it's not possible because XAML is a markup language. It has no support for distinguishing between digits and other type of characters.
您应该使用诸如C#之类的编程语言来实现这种类型的逻辑。
You should use a programming language such as C# to implement this kind of logic.
这篇关于有没有一种方法可以使用WPF xaml代码创建数字文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!