MVVM ViewModel构造函数带参数时,如何连接ViewModel和View

Core_System.xaml.cs:

                public Core_System(ProSimSDK.ProSimConnect connection)//构造函数带参数导致MainWindow.xaml报错
        {
                   ...
                }

MainWindow.xaml:

         <Border Name="Core_System">
            <IOS:Core_System/>//不能用作对象元素,...未定义公共无参数构造函数或类型转换器
        </Border>

MainWindow.xaml.cs构造函数中InitializeComponent()报错:
Object reference not set to an instance of an object.

https://stackoverflow.com/questions/4755617/how-to-i-connect-a-viewmodel-to-a-view-when-the-view-model-has-parameters-in-the?rq=1
上有类似的问题,可我没能找到例子或解决方法,如何解决这个问题?谢谢。

    public ImageSource ImagePath
    {
        get { return (ImageSource)GetValue(ImagePathProperty); }
        set { SetValue(ImagePathProperty, value); }
    }

    public static readonly DependencyProperty ImagePathProperty =
        DependencyProperty.Register("ImagePath", typeof(ImageSource), typeof(ImageButton), new PropertyMetadata(null));

就像这样 你就可以在控件中,使用ImagePath的属性绑定对应的值了

我也遇到过类似的问题,我隐约记得WPF编程宝典中有这样的描述,XAML中的标签其实也都是对象,那么构建这个对象XAML解释器都需要默认的构造方法,所以你在XAML里面,如果你的元素没有无参数构造函数就会报错(我其实不是很理解你这里将ViewModel当做一个UserControl写在XMAL里的这种用法?),如果你是想在ViewModel构建的时候,就传入参数,这里给你两个解决办法:
1.依赖项属性。 把你要传入的参数写成依赖项属性,然后作为参数传入
2.ViewModel中定义普通属性,然后在代码中(OnLoaded事件)给这个ViewModel中的特定属性赋值