Create a UWP Project
Then create a generic C + + run-time project
Right-click on the C + + project and add a C + + class
Defining a class in a header file
#pragmaOncenamespaceimagefactoryrt{ Public ref classImagesrcSealed { Private: Windows::foundation::collections::ivector<int>^colors; intwidth; intheight; Public: Imagesrc (); voidLOADIMAGESRC (windows::foundation::collections::ivector<int>^ Mcolors,intMwidth,intmheight); Public: //int = byte[a] byte[r] byte[g] byte[b]Property windows::foundation::collections::ivector<int>^Colors {windows::foundation::collections::ivector<int>^Get() { returncolors; }; void Set(windows::foundation::collections::ivector<int>^s) {colors=s; }; } PropertyintWidth {int Get() { returnwidth; }; void Set(ints) {width=s; }; } PropertyintHeight {int Get() { returnheight; }; void Set(ints) {height=s; }; } }; Imagesrc::imagesrc () {}voidIMAGESRC::LOADIMAGESRC (windows::foundation::collections::ivector<int>^ Mcolors,intMwidth,intmheight) { This->colors =mcolors; This->width =Mwidth; This->height =Mheight; }}
Introducing in the CPP file
#include "pch.h"
Introducing C + + projects in a UWP project
Classes defined in C + + can be used directly in UWP C #
Public Sealed Partial classMainpage:page { PublicMainPage () { This. InitializeComponent (); IMAGEFACTORYRT.IMAGESRC imagesrc=Newimagesrc (); List<int> list =Newlist<int>(); List. ADD (3); List. ADD (2); List. ADD (1); IMAGESRC.LOADIMAGESRC (list,3,2); Imagesrc.width=1; inth =Imagesrc.height; } }
The main purpose of this is to encapsulate the standard C + + class library using [Standard C + +] ==> [c++/cx] ==> [UWP C #]. Audited by Win10 store.
UWP C # Call C++/CX