-
Notifications
You must be signed in to change notification settings - Fork 962
/
Copy pathmainpage.xaml.cpp
73 lines (57 loc) · 2.07 KB
/
mainpage.xaml.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// MainPage.xaml.cpp
// Implementation of the MainPage class.
//
#include "pch.h"
#include "MainPage.xaml.h"
#include <algorithm>
using namespace ClientApp;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace DelegatesEvents;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/p/?linkid=234238
MainPage::MainPage()
{
InitializeComponent();
}
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
{
//<snippet118>
//Client app
obj = ref new DelegatesEvents::Class1();
CustomStringDelegate^ myDel = ref new CustomStringDelegate([] (ContactInfo^ c)
{
return c->Salutation + " " + c->LastName;
});
IVector<String^>^ mycontacts = obj->GetCustomContactStrings(myDel);
std::for_each(begin(mycontacts), end(mycontacts), [this] (String^ s)
{
this->ContactString->Text += s + " ";
});
//</snippet118>
ContactInfo^ ci = ref new ContactInfo("Ms.", "FrankLynn", "Jones", "1234 Nowhere Mile");
String^ s = ref new String(L"My name is ");
CustomGreeting^ sd = ref new CustomGreeting([&s] (ContactInfo^ c)
{
return s + " " + c->FirstName + c->LastName;
});
obj->StoredDelegate = sd;
String^ s2 = obj->StoredDelegate(ci);
}
void ClientApp::MainPage::Button_Click_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
ContactString->Text = obj->CreateGreeting();
}