我怎样才能使这个 CommandParameter 工作?

How can i make this CommandParameter work?

大学这学期一直在学习WPF,但还是有些地方没有完全理解。我有以下代码:

<UserControl x:Class="Reversi.SquareControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" 
         d:DesignHeight="48" d:DesignWidth="48">
<Button Command="{Binding Place}" CommandParameter="{Binding ????????}">
    ...
</Button>

和:

    public partial class SquareControl : UserControl
{

    public SquareControl(int x, int y)
    {
        InitializeComponent();
        Coordinates = new Vector2D(x, y);
    }

    public Vector2D Coordinates
    {
        get { return (Vector2D) GetValue(CoordinateProperty); }
        set { SetValue(CoordinateProperty, value); }
    }

    ...

    public static readonly DependencyProperty CoordinateProperty =
        DependencyProperty.Register("Coordinates", typeof(Vector2D), typeof(SquareControl), new PropertyMetadata(new Vector2D(0, 0)));
}

我的问题是:我要在 CommandParameter 绑定中放置什么以将 Coordinates 传递到我的 ViewModel 中的 ICommand?

<Window x:Class="WpfApplication2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mine="clr-namespace:WpfApplication2"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <mine:SquareControl Coordinates="{Binding VMCoordinates, Mode=TwoWay}"/>
    </Grid>
</Window>

在这种情况下,命名空间 'mine' 是您应用的命名空间。所以在主 window 中,网格内的线表示 "Place an instance of SquareControl in my view and bind it's DP called Coordinates to a property on the VM called VMCoordinates"

'Mode=TwoWay' 表示如果视图(用户)或 VM 更改了数据,则将其传递给另一个。