UWP:无法从 'int' 转换为“Windows.UI.Xaml.DependencyProperty”

UWP: Cannot convert from 'int' to 'Windows.UI.Xaml.DependencyProperty"

我正在开发一个 UWP 应用程序,我想在其中绑定代码背后的一些属性。目前,我有以下内容:

Sample.xaml

<Grid>
  <Border Margin="0">
  <controls:Carousel x:Name="CarouselControl"
              InvertPositive="True"
              ItemDepth="300"
              ItemMargin="{Binding ItemsMargin}"
              ItemRotationX="0"
              ItemRotationY="45"
              ItemRotationZ ="0"
              Orientation="Horizontal"
              SelectedIndex="4">
    <controls:Carousel.EasingFunction>
      <CubicEase EasingMode="EaseOut" />
    </controls:Carousel.EasingFunction>
    <controls:Carousel.ItemTemplate>
      <DataTemplate>
        <Image Width="200"
              Height="200"
              VerticalAlignment="Bottom"
              Source="{Binding Thumbnail}"
              Stretch="Uniform" />
      </DataTemplate>
    </controls:Carousel.ItemTemplate>
  </controls:Carousel>
</Border>

背后的代码

  public sealed partial class Sample
  {
      private int itemsMargin;
      public int ItemsMargin
    {
        get => this.itemsMargin;
        set => this.SetValue(this.itemsMargin, value);
    }
  }

我在 this.SetValue 上收到一条错误消息,即参数 1:无法从 'int' 转换为 'Windows.UI.Xaml.DependencyProperty'。对理解这一点的任何帮助表示赞赏。

DependencyObject.SetValue Method requires a DependencyProperty 和一个对象作为参数。 Int 不是 DependencyProperty。

请改用以下代码:

  private int itemsMargin;
    public int ItemsMargin
    {
        get => this.itemsMargin;
        set => this.itemsMargin = value;
    }