问题描述
我在一个窗口中有多个用户控件。每个用户控件都有一个文本框(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.
推荐答案
这篇关于使用WPF-MVVM中的用户控件值绑定数据网格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!