明らかに何かが間違っている必要がありますが、わかりません。xamltypeinfo.g.cppのC++コンパイラエラー
私はブランクのC++メトロアプリを作成しました。私はUIにバインドするモデルを追加しましたが、xamltypeinfo.g.cpp
に関連するコンパイラエラーが発生しています。逃した。
私のヘッダファイルには、次のようになります。
#pragma once
#include "pch.h"
#include "MyColor.h"
using namespace Platform;
namespace CppDataBinding
{
[Windows::UI::Xaml::Data::Bindable]
public ref class MyColor sealed : Windows::UI::Xaml::Data::INotifyPropertyChanged
{
public:
MyColor();
~MyColor();
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;
property Platform::String^ RedValue
{
Platform::String^ get()
{
return _redValue;
}
void set(Platform::String^ value)
{
_redValue = value;
RaisePropertyChanged("RedValue");
}
}
protected:
void RaisePropertyChanged(Platform::String^ name);
private:
Platform::String^ _redValue;
};
}
と私のcppファイルは次のようになります。
#include "pch.h"
#include "MyColor.h"
using namespace CppDataBinding;
MyColor::MyColor()
{
}
MyColor::~MyColor()
{
}
void MyColor::RaisePropertyChanged(Platform::String^ name)
{
if (PropertyChanged != nullptr)
{
PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(name));
}
}
あまりにもトリッキー何もないが、私はMyColor
であることを示すxamltypeinfo.g.cpp
のエラーを取得するコンパイルするときCppDataBinding
で定義されていません。私はコードがコンパイルMyColor
からBindable
属性を削除した場合
if (typeName == "CppDataBinding.MyColor")
{
userType = ref new XamlUserType(this, typeName, GetXamlTypeByName("Object"));
userType->Activator = ref new XamlTypeInfo::InfoProvider::Activator(
[]() -> Platform::Object^
{
return ref new CppDataBinding::MyColor();
});
userType->AddMemberName("RedValue", "CppDataBinding.MyColor.RedValue");
userType->SetIsBindable();
xamlType = userType;
}
:
関連生成されたコードは次のようになります。
誰かがぼんやりと明白なことを私に教えてもらえますか?私は自分自身に顔面を置き、問題を解決できますか?
明らかに間違っていたことは、あなたがここで使っているものは何でも、C++ではないということです。 –
コンパイラはどのようなエラーメッセージを表示しますか? –
このxor "^"は "Platform :: String ^"とは何ですか? –