简体   繁体   English

动态XAML和事件处理

[英]Dynamic XAML and events handling

I have a WPF Window that was created dynamically by loading a XAML script, which is part of a bigger script(Proprietary) that we support. 我有一个WPF窗口,该窗口是通过加载XAML脚本动态创建的,该脚本是我们支持的较大脚本(专有)的一部分。

This Script contains supports for user actions like text box lost focus / Check box checked / Button clicked etc.. 该脚本包含对用户操作的支持,例如文本框失去焦点/复选框被选中/按钮被点击等。

Say I have a pre written C# class meant to support functionalities of the class. 假设我有一个预先编写的C#类,旨在支持该类的功能。

Since the windows is dynamic it might contain any number of basic UI element like button, radio button check box edit box etc. 由于窗口是动态的,因此它可能包含任意数量的基本UI元素,例如按钮,单选按钮复选框编辑框等。

How do I link XAML to every possible action on the dialog box, like text box lost focus / Check box checked / Button clicked etc. 如何将XAML链接到对话框上的每个可能的操作,例如文本框失去焦点/选中复选框/单击按钮等。

Ideally if I can get Name of the UI Element Action and a string from XAML into C# class that is perfect. 理想情况下,如果我可以获取UI元素操作的名称以及从XAML到C#类的字符串,那是完美的。

example Button1, "Clicked" "Button1_Clicked" here Button1_Clicked is a string that has been passed from XAML which helps me call the function “Button1_Clicked” in my scripting 例如Button1,“ Clicked”,“ Button1_Clicked”,这里的Button1_Clicked是从XAML传递来的字符串,可以帮助我在脚本中调用函数“ Button1_Clicked”

language. 语言。 Similarly for a text Box it could be Text1, "LostFocus" "Text1_LostFocus" etc.. 同样,对于文本框,它可以是Text1,“ LostFocus”,“ Text1_LostFocus”等。

How can I write my supporting class and the XAML script to achieve the above mentioned scenario.. 如何编写支持类和XAML脚本来实现上述方案。

just have a look at this post 看看这个帖子

Loading XAML XML through runtime? 通过运行时加载XAML XML?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM