使用WPF-MVVM中的用户控件值绑定数据网格行 [英] Bind datagrid row with user control values in WPF-MVVM

查看:187
本文介绍了使用WPF-MVVM中的用户控件值绑定数据网格行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个窗口中有多个用户控件。每个用户控件都有一个文本框(txtGoodQty)。双击该文本框打开一个窗口,里面有一个数据网格。我想将用户控件的值绑定到数据网格行。如何使用MVVM实现它?

我们可以在这里使用依赖属性,但我不知道如何使用它进行绑定。



我尝试了什么:



我做了这个

I have multiple user control's in a window.Every User Control has a text box (txtGoodQty).On Double click of that text box opens a Window which has a data grid inside.I want to bind the user control's value to the data grid row.How can i achieve it using MVVM?
Can we use dependency property here, but i am not aware how to use it for binding.

What I have tried:

I did this

<TextBox.InputBindings>
               <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding DataContext.testmethod,
                                       RelativeSource={RelativeSource FindAncestor,
                                       AncestorType={x:Type UserControl}}}"/>
               <!--CommandParameter="{Binding .}"/>-->
           </TextBox.InputBindings>





在某些方法中我称之为窗口的show属性。

但现在我我对用户控件值绑定到datagrid行感到困惑。



and in the somemethod i called the show property of window.
But now I am stucked up with bindings of user control values to the datagrid row.

推荐答案

我对你要做的事情感到有些困惑,但你确实有CommandParameter哪个传递控件的值。
I am somewhat confused about what you are trying to do, but you do have the CommandParameter with which to pass the control's value.


这篇关于使用WPF-MVVM中的用户控件值绑定数据网格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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