将Button.Content从一个用户控件传递到另一个 [英] Pass Button.Content From one User Control to the Other

查看:61
本文介绍了将Button.Content从一个用户控件传递到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在研究wpf
我的问题如下:
我有一个开放的wpf用户控件,叫它UC1
当用户单击按钮时,另一个wpf用户控件(UC2)将打开
他会选择一个在上面写文字的按钮
我想将此按钮的内容传递给UC1而不关闭它并修改它的内容!


Hello I''m working on wpf
my Problem is the following :
I have an open wpf user control let''s call it UC1
When the user clicks a button another wpf user Control (UC2) will open
he''ll choose a button on which a text is written
I want to pass this button''s content to UC1 without closing it and modify its content!


How can I do such thing?

推荐答案

在这种情况下,我不会将内容直接传递给另一个用户控件.相反,您可以利用MVVM模式.

一些链接:
- MVVM模式变得简单 [具有Model-View-ViewModel设计模式的WPF应用 [
I wouldn''t pass the contents directly to another user control in such situation. Instead you could utilize the MVVM pattern.

Some links:
- MVVM Pattern Made Simple[^]
- WPF Apps With The Model-View-ViewModel Design Pattern[^]


我同意Mika:您应该将数据从数据层传递到控件,反之亦然,而不是从控件传递到控件.

我还想指出,没有打开控制"或关闭控制"这样的概念,因此您甚至在说什么也不十分清楚.

—SA
I agree with Mika: you should pass data from data layer to controls and visa versa, not from control to control.

I also want to note that there is no such concept as "open control" or "close control", so it''s not quite clear what are you even talking about.

—SA


这篇关于将Button.Content从一个用户控件传递到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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