0

我有以下课程:

namespace MainProject.Model
{
   public class ModelObject: INotifyPropertyChanged
   {
     public int Value{ get; set; }
   }
}

我尝试在我的模板中使用它x:Bind

 <DataTemplate x:Key="ListViewItemTemplate" x:DataType="model:ModelObject">
    <my:CustomSelector Grid.Column="1" ActualValue="{x:Bind Value}" />
</DataTemplate>

在构建时,我总是收到此消息:

XBF 语法错误“0x09C4”:找不到属性。检查您在 XAML 中设置的属性是否存在于项目中指定的平台的最低版本 (TargetPlatformMinVersion)

根据这个,我必须设置 Windows 的最低版本,我这样做了:

在此处输入图像描述

我还尝试在主项目而不是模型项目中创建本地后代,以使命名空间相同:

namespace MainProject.UWP
  {
       public class UWPModelObject: ModelObject
      {
      }
  }

我还应该做什么?

4

1 回答 1

0

尝试这个:

public class ModelObject : INotifyPropertyChanged
{
    public int DaValue
    {
        get { return _daValue; }
        set
        {
            _daValue = value;
            OnPropertyChanged();
        }
    }

    private int _daValue;




    public event PropertyChangedEventHandler PropertyChanged;


    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

int 是正确的类型吗?还是应该使用字符串!?

编辑:在 MainPage.cs 中设置数据上下文,如下所示:

public MainPage()
    {
        this.InitializeComponent();
        ModelObject modelObject = new ModelObject();
        DataContext = modelObject;
    }
于 2016-09-29T17:02:51.987 回答