Samples Silverlight int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { // Initialisierung der XAML Runtimeif (!XamlRuntimeInitialize()) return -1; Each Silverlight for Windows Embedded application has a single "application" object that can be used to access global properties. To access this object the GetXRApplicationInstance API is used.
HRESULT retcode; // Load an dinit XAML resource IXRApplicationPtr app; if (FAILED (retcode=GetXRApplicationInstance(&app))) return -1; if (FAILED (retcode=app->AddResourceModule(hInstance))) return -1; After the initialization of the application object, the main window can be created and the administration of the object can be handed over to Silverlight for Windows Embedded.
XRWindowCreateParams wp; ZeroMemory(&wp, sizeof(XRWindowCreateParams)); // Set window styles wp.Style = WS_BORDER; wp.pTitle = L"Silverlight for Windows Embedded Machine Sample"; wp.Left = 0; wp.Top = 0; wp.AllowsMultipleThreadAccess = true; XRXamlSource xamlsrc; xamlsrc.SetResource(hInstance, TEXT("XAML"), MAKEINTRESOURCE(IDR_XAML1)); if (FAILED(retcode=app->CreateHostFromXaml(&xamlsrc, &wp, &vhost))) return -1; The object within a Silverlight for Windows Embedded application is organized in object trees. In order to access this object, a pointer to the root element is required.
IXRFrameworkElementPtr root; if (FAILED (retocde=app->CreateHostFromXaml(&xamlsrc, &wp, &vhost))) return -1; Creating instances of the controls and timelines. // Get controls by nameif (FAILED(retcode=root->FindName(TEXT("butClose"), &butClose))) return -1; if (FAILED(retcode=root->FindName(TEXT("radSpeedSlow", &radSpeedSlow))) return -1; if (FAILED(retcode=root->FindName(TEXT("radSpeedFast", &radSpeedFast))) return -1; if (FAILED(retcode=root->FindName(TEXT("txtDeviceDown", &txtDeviceDown))) return -1; if (FAILED(retcode=root->FindName(TEXT("txtDeviceUp", &txtDeviceUp))) return -1; TX1000 20 Version: 1.2