这个学期我在大学里一直在学习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?