martes, 15 de septiembre de 2015

C++/CX & Xaml Data Binding

There is a few methods that you can use to make a C++/CX class with data-bindable capability. The most simple way is by adding an attribute to the class declaration:


[Windows::UI::Xaml::Data:Bindable]

public ref class SampleDataClass sealed
{
...
};


But, What about non-public classes? With the non-public classes you can declare the class by implementing either the ICustomPropertyProvider interface or IMap:


ref class SampleDataNonPublicClass sealed : Windows::UI::Xaml::Data::ICustomPropertyProvider
{
...
public:
virtual Windows::UI::Xaml::Data::ICustomProperty^ GetCustomProperty(Platform::String^ name);
virtual Windows::UI::Xaml::Data::ICustomProperty^ GetIndexedProperty(Platform::String^ name, Windows::UI::Xaml::Interop::Type type)
property Windows::UI::Xaml::Interop::TypeName Type
{
virtual Windows::UI::Xaml::Interop::TypeName get() { return this->GetType(); }


}

virtual Platform::String^ GetStringRepresentation()
{return this->ToString();
} };

No hay comentarios:

Publicar un comentario