如何在标记

时间:2015-10-02 19:29:38

标签: c# wpf mvvm

我的MouthDiseaseViewModel中有一个方法

public void Insert(MouthDisease entity, DetailsUserControl userCon)
{
    //some code for saving to the db    
}

如何将这两个参数(1个MouthDisease对象和一个UserControl)传递给命令按钮参数?

<Button Content="Update" Command="{Binding MouthInsertCommand}" >
        <Button.CommandParameter>
            <Binding></Binding><!--stuck here-->
        </Button.CommandParameter>                    
</Button>

修改

这不是重复的!我看到了Peter提供的链接,它有两个具有相同类型和相同元素的参数。我指出我的参数是来自ViewModel的对象和来自视图的当前UserControl。我见过的所有样本都是关于宽度和高度,或者是具有相同数据类型的标签和名称。

无论如何,正如曾指出的那样,我违反了这种模式。我认为View和Model是唯一不应该相互引用的类。

所以当我编辑它时,如果我的ViewModel.Insert的签名是这样的:

public void Insert(MouthDisease entity, User currentUser)
{
    //some code for saving to the db    
}

如何在标记中使用两种不同的数据类型编写此方法?

0 个答案:

没有答案
相关问题