Project DescriptionGives you the power of C++ at a cost of the simplicity of C#.
C# to C++/CX Converter allows you to translate C# code into C++ /CX code.
C# files in Solution Explorer
C# original file
using Platform;
using Windows.UI.Xaml.Data;
namespace App1.Common
{
/// <summary>
/// Implementation of <see cref="INotifyPropertyChanged"/> to simplify models.
/// </summary>
[Windows.Foundation.Metadata.WebHostHidden]
public abstract class BindableBase : Windows.UI.Xaml.DependencyObject,
Windows.UI.Xaml.Data.INotifyPropertyChanged,
Windows.UI.Xaml.Data.ICustomPropertyProvider
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public virtual event PropertyChangedEventHandler PropertyChanged;
// ICustomPropertyProvider
public virtual Windows.UI.Xaml.Data.ICustomProperty GetCustomProperty(string name)
{
return null;
}
public virtual Windows.UI.Xaml.Data.ICustomProperty GetIndexedProperty(string name, Windows.UI.Xaml.Interop.TypeName type)
{
return null;
}
public virtual string GetStringRepresentation()
{
return this.ToString();
}
public virtual Windows.UI.Xaml.Interop.TypeName Type
{
get { return this.GetType(); }
}
/// <summary>
/// Notifies listeners that a property value has changed.
/// </summary>
/// <param name="propertyName">Name of the property used to notify listeners.
protected void OnPropertyChanged(string propertyName)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
C++ result header file
#pragma once
namespace App1
{
namespace Common
{
[Windows::Foundation::Metadata::WebHostHidden]
public ref class BindableBase: public Windows::UI::Xaml::DependencyObject, Windows::UI::Xaml::Data::INotifyPropertyChanged, Windows::UI::Xaml::Data::ICustomPropertyProvider
{
public: virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;
public: virtual Windows::UI::Xaml::Data::ICustomProperty^ GetCustomProperty(Platform::String^ name);
public: virtual Windows::UI::Xaml::Data::ICustomProperty^ GetIndexedProperty(Platform::String^ name, Windows::UI::Xaml::Interop::TypeName type);
public: virtual Platform::String^ GetStringRepresentation();
public: property Windows::UI::Xaml::Interop::TypeName Type
{
public: virtual Windows::UI::Xaml::Interop::TypeName get();
};
protected: void OnPropertyChanged(Platform::String^ propertyName);
};
}
}
C++ result code file
#include "pch.h"
#include "BindableBase.h"
using namespace Platform;
using namespace Windows::UI::Xaml::Data;
using namespace App1::Common;
ICustomProperty^ BindableBase::GetCustomProperty(String^ name)
{
return nullptr;
}
ICustomProperty^ BindableBase::GetIndexedProperty(String^ name, Windows::UI::Xaml::Interop::TypeName type)
{
return nullptr;
}
String^ BindableBase::GetStringRepresentation()
{
return this->ToString();
}
Windows::UI::Xaml::Interop::TypeName BindableBase::Type::get()
{
return this->GetType();
}
void BindableBase::OnPropertyChanged(String^ propertyName)
{
this->PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
}
C# to C++/CX Converter Properties Page
