Windows runtime C+的CX视图+;班级 我正在编写一个程序,它有一个可移植的C++后端,我们要为它创建一个WRRT-XAML前端。我想让我们的模型保持在纯C++代码中,并在C++中创建一个视图,它反映了我们可以在前端传递和消费的C++模型。这有什么标准方法吗
例如:Windows runtime C+的CX视图+;班级 我正在编写一个程序,它有一个可移植的C++后端,我们要为它创建一个WRRT-XAML前端。我想让我们的模型保持在纯C++代码中,并在C++中创建一个视图,它反映了我们可以在前端传递和消费的C++模型。这有什么标准方法吗,windows-runtime,c++-cx,Windows Runtime,C++ Cx,例如: class Person { public: const std::wstring GetName() const; void SetName(const std::wstring& value); private: std::wstring m_Name; } ref class PersonMirror : INotifyPropertyChanged { public: property Platform::String^ Name
class Person
{
public:
const std::wstring GetName() const;
void SetName(const std::wstring& value);
private:
std::wstring m_Name;
}
ref class PersonMirror : INotifyPropertyChanged
{
public:
property Platform::String^ Name
{
Platform::String^ get();
void set(Platform::String^ value);
}
private:
std::shared_ptr<Person> m_Person;
}
班级人员
{
公众:
常量std::wstring GetName()常量;
void SetName(const std::wstring和value);
私人:
std::wstring m_Name;
}
ref class PersonMirror:INotifyPropertyChanged
{
公众:
属性平台::字符串^Name
{
平台::字符串^get();
无效集(平台::字符串^value);
}
私人:
std::共享ptr m_人;
}
在这种情况下,我不知道怎么做:
- 如何从本机类获取关联的ref-mirror类。我可以将void*转换为PersonMirror^并与GC讨论保留对该对象的引用吗
- 是否有C++触发事件的实现?或者我想,如果我能保持这是一个1对1的关系,我也许可以使用函数指针
:在同一过程中,可以使用REF类和ISO C++类之间的任何EvoDebug机制。唯一的限制是ref类中的任何公共类型都必须与WinRT兼容。要在PersonMirror中公开回调或函数对象事件处理程序,请为其提供内部可访问性,使其对WinRT接口不可见,但您的ISO代码仍然可以访问它
MSDN上的示例演示了一个由C++ /CX包装类包装的ISO C++类。< /P>是否真的需要为每个C++类创建一个CX包装器?