简体   繁体   English

在这种情况下,如何在用户控件中启用事件处理程序

[英]In this case, how enable the event handler in a user control

I have a user control that got an image, two textblock, button & integer (in the code class non UI). 我有一个用户控件,该控件具有图像,两个文本块,按钮和整数(在非UI代码类中)。 I have bind this control to the DB and add it in a list with no issues. 我已将此控件绑定到数据库,并将其添加到列表中,没有任何问题。

But the only thing that is left is. 但是唯一剩下的就是。 I would like whenever I press the button it pulls the number from the integer in the control and compare that number with the DB and return a result. 我希望每当我按下按钮时,它就会从控件中的整数中提取数字并将该数字与DB进行比较并返回结果。

Please advise me since I don't know how to do this. 请告诉我,因为我不知道该怎么做。

A good place to start will be http://wpftutorial.net/ where you can lear a lot about WPF and MVVM. 一个很好的起点是http://wpftutorial.net/ ,在这里您可以学到很多有关WPF和MVVM的知识。 Some good key words for you to search and learn in google will be: MVVM WPF Binding WPF Command MVVM light 您可以在Google中搜索和学习的一些好关键词是:MVVM WPF绑定WPF命令MVVM light

These keywords will give you a good start on learning more WPF 这些关键字将为您提供学习WPF的良好开端。

In relation to your question above you need to: 1. handle the button click 2. do something 3. place the result in the required textblock 关于上述问题,您需要:1.处理按钮单击2.做一些事情3.将结果放入所需的文本块中

<Button click="some_method_name"/>

public void some_method_name()
{
    // do something
    textBlock.Text = result;
}

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

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