Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在标记中传递对象和用户控件多个参数_C#_Wpf_Mvvm - Fatal编程技术网

C# 如何在标记中传递对象和用户控件多个参数

C# 如何在标记中传递对象和用户控件多个参数,c#,wpf,mvvm,C#,Wpf,Mvvm,我在my MoutDiseaseViewModel中有一个方法 public void Insert(MouthDisease entity, DetailsUserControl userCon) { //some code for saving to the db } 如何将这两个参数(1个对象和一个用户控件)传递给命令按钮参数 <Button Content="Update" Command="{Binding MouthInsertCommand}" >

我在my MoutDiseaseViewModel中有一个方法

public void Insert(MouthDisease entity, DetailsUserControl userCon)
{
    //some code for saving to the db    
}
如何将这两个参数(1个对象和一个用户控件)传递给命令按钮参数

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

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

看看这个问题-您可以创建一个实现IMultiValueConverter的WPF converter类,而不是命令,它可以根据需要接收多个值。您应该到此为止。您所做的违反了MVVM模式,显然是错误的。不允许ViewModel对视图进行任何引用。要实现这一点,您必须为视图、ViewModels和其他域模型、服务等创建多个程序集,并且ViewModel程序集不得引用视图程序集或任何与Presentation.dll/WPF相关的程序集。此时是否确实需要传递第二个参数?为什么MouseDiseaseViewModel不能在其构造函数中获取当前用户的引用?
public void Insert(MouthDisease entity, User currentUser)
{
    //some code for saving to the db    
}