动态XAML脚本对话框 [英] dynamic XAML Scripting dialog

查看:92
本文介绍了动态XAML脚本对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#/WPF重写一个庞大的MFC/C ++老项目.
在这个项目中,我们支持脚本语言,这是我们在C/C ++中开发的.
脚本(文本文件)允许用户做很多事情,还允许创建带有基本UI元素的对话框.它在内部创建一个MFC对话框.
如何使用WPF和XAML做到这一点?
加载创建对话框的XAML脚本很简单,但是无论如何我都想使用对话框中的值进行一些处理.
我该如何实现?
举例来说,我有一个简单的WPF应用程序,可加载脚本. (这只是一个例子)
脚本的工作是在文本框中显示一个简单的对话框,其中包含2个浮点数.
然后,我有4个单选按钮,分别显示加/减/乘和除运算.
和一个计算按钮.当用户按下计算按钮时,应在消息框中显示结果,并在数字之间进行正确的操作.
以上所有操作均应仅通过脚本完成.
还有一个确定按钮可以关闭对话框,但是当他关闭对话框时,我想将对话框中的值保留到某种数据结构中.
非常感谢在这方面的任何帮助.
多亏了Advance的帮助.

I am trying to rewrite a huge old MFC/C++ project using C# /WPF.
In this project we support scripting language something that we developed here in C/C++
The scripting(text files) allows the user to do many things also allows create a dialog with basic UI elements. Internally it creates a MFC Dialog.
How can I do this using WPF and XAML ?
It is simple to load a XAML Script that creates the dialog how ever say I want to carry out some processing using the values in the dialog.
How can I achieve that?
Say for instance I have a simple WPF application that loads a script. ( This is just an example)
Job of the script is to show a simple dialog box with 2 float numbers in text boxes.
Then I have 4 radio buttons that show the operation Add / Subtract / Multiply and Divide.
And a Calculate button. When user presses the calculate button It should show the result in a message box carrying out the right operation between the numbers.
All the above should be done through only script.
And a OK button that closes the dialog, however when he closes the dialog I want to retain values from the dialog into some sort of Data Structure.
Any help in this regard is greatly Appreciated.
Thanks a bunch in Advance.

推荐答案

据我所知,没有"XAML脚本"这样的概念.

为了更好地理解它是什么,请转至基础知识: http://en.wikipedia.org/wiki/XAML [ ^ ].

当然,您可以使用XAML动态创建一些控件或窗口,但是它与脚本(主要面向命令式编程)不一样,而XAML几乎都是声明性的.如果您以前使用的脚本已经基于脚本系统,那么我不确定XAML是否可以满足您的需求.

当然,您可以在XML上实现任何类型的脚本语言.

您可以创建语言(甚至是命令性语言)的数据模型,并开发一些引擎,该引擎将在语义上执行模式实例.任何进一步的讨论都应或多或少地涉及您的功能需求的完整规范(将这些最终需求与您的技术观点隔离开来,以避免沉迷于印记的解决方案很重要).不幸的是,这似乎超出了我们快速问答的格式.

—SA
There is no such notion as "XAML script", to best of my knowledge.

To better understand what it is, go to the basics: http://en.wikipedia.org/wiki/XAML[^].

Of course you can use XAML to dynamically create some controls or windows, but it does not resemble scripting which is mostly oriented to imperative programming while XAML is pretty much all declarative. If what you had before was already based on scripting system, I''m not sure XAML can fit your needs.

You can implement any type of scripting language on XML, of course.

You can create a data model of your language (even imperative) and develop some engine which would execute the instance of the schema semantically. Any further discussion should involve more or less full specification of your functional requirements (its important to isolate those ultimate requirement from your technological views to avoid preoccupation with the imprinted solutions). Unfortunately it seems to be somewhat beyond the format of our quick Questions-and-Answers.

—SA


您可以使用.NET(使用XAML课程)并将其构建为程序集(Dll).稍后从您的应用程序中加载程序集.这里的Dll将是您的脚本文件.

.NET具有非常灵活的库来处理程序集.
Instead of Scripting of XAML (which is not effective as you are talking), you can write your Dialog as a Control Library in .NET (using XAML of-course) and build it as Assembly (Dll). Later load the Assembly from your application. Here the Dll will be your scripting file.

.NET has very flexible library to handle an Assembly.


这篇关于动态XAML脚本对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆