Posts
77
Comments
212
Trackbacks
0
Silverlight for Windows Embedded tutorial

Windows Embedded CE 6.0 R3 has been released yesterday, you can download it from here:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=bc247d88-ddb6-4d4a-a595-8eee3556fe46
One of the most exciting new features of R3 is Silverlight for Windows Embedded.
With this technology the UI of an application can be described using XAML, an XML-based language, and can be designed using visual tools like Expression Blend.
This will allow UI designers to work on embedded devices using the same tools they use on the desktop and it will let embedded developers concentrate on the core application features and not on the design of the UI.
I hope that this will lead to visually pleasing but also more user friendly interfaces on any kind of embedded device. Using visual tools for UI design should also improve development time and allow minor fixes to the UI without code modifications. This will improve device development times and reduce maintenance costs.
This simple tutorial will show how you can design a very basic UI in Expression Blend 2, load it inside an application and interact with it.
The first step you need to perform is include the components needed to support Silverlight for Windows Embedded inside your OS Image and rebuild it.
Jochen Dieckfoß provided a good description of that process on his blog here:
http://discovertheexperience.blogspot.com/2009/09/windows-embedded-ce-60-r3-using.html
Now that you have an OS image supporting Silverlight for Windows Embedded you can start to design your UI.
Start Expression Blend and create a new Silverlight application.

You'll have to use Expression Blend 2 SP1 (thanks Shai for the useful advice!) because this is the release that support Silverlight 2, the version that is currently supported on embedded devices.
This will create a Visual Studio solution (that we don't need for this tutorial).
As you can see the wizard allows you to choose a language between C# and Visual Basic. Silverlight for Windows Embedded supports only C++ programming and it's currently not integrated with Expression Blend, so you'll not use the source code generated by this tool.
Remember to disable Visual Studio integration inside Expression Blend or it will generate C# or VB.NET code for event handlers etc.

After you created a new project, Expression Blend will present you with an empty XAML document (named page.xaml by default).

We can draw a simple button inside it picking it from the rich collection of controls provided by Silverlight.

Using the properties window we can assign a name to our new button.

The properties toolbox allows you to customize many aspects of your button: it's colors, it's rotation (yes you can have a vertical button or a button turned at 45 degrees!), it's opacity etc.
We will experiment with all these features in the next tutorials, for now we will keep the button as is and save our XAML.
If you open the XAML file using a text editor or view it using the XAML view inside Expression Blend you'll see that it's quite simple:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SimpleApp.Page" 
Width="640" Height="480">
    <Grid x:Name="LayoutRoot" Background="White">
        <Button Height="87" Margin="189,106,209,0" VerticalAlignment="Top" Content="Button" 
x:Name="MyButton"/>
    </Grid>
</UserControl>


We have a top level container (UserControl) that uses a Grid layout (objects are organized in rows and columns) and contains our button.
The button has attributes for placement inside its own grid cell (the only one we have), alignment, content (the text "Button") and its name ("MyButton").
Now we can start Platform Builder and add a new subproject to our OS Design.
You may develop your Silverlight for Windows Embedded application also using Visual Studio 2005 or 2008 Smart Device application if you generate an SDK from your R3 OS design and install it on your development PC, but for this tutorial we will keep things simple...
Move to the solution tab, right click on the subprojects node and select "add new...".
Create a Win32 application.

And choose the simple Win32 application template.

This will create an application containing only WinMain, it's enough to start experimenting with our first Silverlight for Embedded UI.
The first thing we should do is add the Silverlight for Windows Embedded includes to our source code:

#include "pwinuser.h"
#include "xamlruntime.h"
#include "xrdelegate.h"
#include "xrptr.h"


We will add the XAML that we generate with expression blend to our application resources. In this way we will not need to distibute the XAML file with it. On the other side changes to the XAML will require a rebuild of the application, you may choose the best method to integrate XAML and C++ source code in your application.
To include resources inside your executable file you need to add a resource script (rc file) to your subproject.
Right click on the subproject in solution view, select "add\new item" and then select resource file from the dialog box and assign a name to it (usually you have only one resource file per application so using the application name for that file sounds like a good idea).

Now that you have your resource file you can add the XAML data to it by creating a new resource.
Go to the "resource view" tab, right click on your resource file and select "add resource..."

Now you can import your XAML file data inside your executable. It will be stored inside it (at the end of the file) as binary data.

Type "XAML" as resource type.

For the tutorial you can leave the default ID (IDR_XAML1) for that resource, but it's a good idea to give meaningful names to your XAML components in a real project.

To use our resource IDs we need to include "resource.h" inside our .cpp file:

#include "resource.h"


Then, inside our application main function (WinMain) we can start to interact with the XAML runtime.
First of all we need to initialize it:

    if (!XamlRuntimeInitialize())
        return -1;


If XamlRuntimeInitialize succeeded, the Silverlight for Windows Embedded runtime is loaded inside your application and it's ready to handle the UI.
Each Silverlight for Windows Embedded application has a singleton "Application" object that allows us to access global application properties and features.
To access it we should use the GetXRApplicationInstance API.

    HRESULT retcode;

    IXRApplicationPtr app;
    
    if (FAILED(retcode=GetXRApplicationInstance(&app)))
        return -1;



Someone will notice that we are using HRESULTs and classes that use the "I" prefix and the "Ptr" suffix and understand that this new technlogy is based on COM (Component Object Model) that may sound like an ancient tool in those .NET and managed code days but it's still the foundation of many technlogies on both CE and desktop Windows releases. All Silverlight for Windows Embedded objects are implemented as COM objects that export specific interfaces (COM interfaces have names beginning with "I"). Since using interfaces directly requires handling of their reference count and this may lead to memory leaks or premature object deletions, COM programmers prefer to use "smart pointers" that are wrappers around the interfaces and manage reference counting internally, destroying the COM object when the smart pointer object goes out of scope inside your C++ application (function return if it's allocated on the stack, object destruction if it's declared as a class member etc.). Smart point classes add the "Ptr" suffix to the interface name.
After this 30 seconds introduction to COM, we can return to our application.
The first thing we have to do with our application object is tell it where it can find its resources (XAML, images etc.).
We included them inside the executable using the resource file and so we can pass our HINSTANCE handle to it:

    if (FAILED(retcode=app->AddResourceModule(hInstance)))
        return -1;


Now that we have initialized our application object we can create our main window and let Silverlight for Windows Embedded manage its contents:

    XRWindowCreateParams wp;

    ZeroMemory(&wp, sizeof(XRWindowCreateParams));

    wp.Style       = WS_OVERLAPPED;
    wp.pTitle      = L"S4E Test";
    wp.Left        = 0;
    wp.Top         = 0;

    XRXamlSource xamlsrc;

    xamlsrc.SetResource(hInstance,TEXT("XAML"),MAKEINTRESOURCE(IDR_XAML1));

    IXRVisualHostPtr vhost;

    if (FAILED(retcode=app->CreateHostFromXaml(&xamlsrc, &wp, &vhost)))
        return -1;


The VisualHost object "hosts" the runtime and allows us to access its contents and load our XAML from resources (using the XRXamlSource object).
Now our XA
The object inside our Silverlight for Windows Embedded application are organized in a objects tree. To access the object inside it we need a pointer to its root:

    IXRFrameworkElementPtr root;

    if (FAILED(retcode=vhost->GetRootElement(&root)))
        return -1;


From the root object we can access our button using the name we assigned to it inside Expression Blend:

    IXRButtonBasePtr btn;
    
    if (FAILED(retcode=root->FindName(TEXT("MyButton"), &btn)))
        return -1;


To receive a notification when the user clicks our button we need to provide a delegate. A delegate is a pointer to a member of an istance of a C++ class that should have a specific prototype.
We can declare a simple C++ class inside our .cpp source and implement our button click event delegate inside it:

class BtnEventHandler
{
public:

    HRESULT OnClick(IXRDependencyObject* source,XRMouseButtonEventArgs* args)
    {
        MessageBox(NULL,TEXT("Click!"),TEXT("Silverlight for Windows Embedded test"),MB_OK);
        return S_OK;
    }
};


Our event handler will simply display a message box when the button is clicked.
As you can see the event handler takes two parameters. A pointer to the object that generates the event (our button) and a pointer to a structure that contains the event parameters.

To connect our event handler to the button we have to create a delegate object:

    BtnEventHandler handler;

    IXRDelegate<XRMouseButtonEventArgs>* clickdelegate;

    if (FAILED(retcode=CreateDelegate(&handler,&BtnEventHandler::OnClick,&clickdelegate)))
        return -1;

    if (FAILED(retcode=btn->AddClickEventHandler(clickdelegate)))
        return -1;


Our event handler has been connected to the button, now we can show our UI and wait that the user presses our wonderful button:

    UINT exitcode;

    if (FAILED(retcode=vhost->StartDialog(&exitcode)))
        return -1;


Our clickdelegate object is not a smart pointer, so we will have to release it explicitly:

    clickdelegate->Release();


Before we can build our subproject we need to add the include directories and the libraries needed to support Silverlight for Windows Embedded inside our application.
Open the subproject sources script by right clicking on the subproject and choosing "open".
Add includes:

INCLUDES=$(_OEMINCPATH)

and libraries:

TARGETLIBS= \
    $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib \
    $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\xamlruntime.lib \
    $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\uuid.lib \


(you should already have the TARGETLIBS directive inside your sources script)
Now you can run the application on your device and push that button!

You, like me, are too lazy to type sample code, you can download a zip containing our demo application here:
http://cid-9b7b0aefe3514dc5.skydrive.live.com/self.aspx/.Public/SilverlightSample.zip

You can find the next step here:
http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/10/11/silverlight-for-embedded-tutorial-step-2.aspx

posted on Thursday, October 1, 2009 2:35 PM Print
Comments
Gravatar
# re: Silverlight for Embedded tutorial
Shai
10/4/2009 7:52 AM
Hi Valter,
Thanks for the Tut. I just started going through it. You should update that one needs Expression Blend 2 SP1, otherwise you won't have the silverlight application project type available.

Regards,
Shai
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/4/2009 8:53 AM
You are right shai, you need to install Expression Blend SP1 to have Silverlight 2 support.
Gravatar
# re: Silverlight for Embedded tutorial
Prabu
10/8/2009 6:03 AM
Thanks for this great tutorial.One of the Best for the beginners.Keep posting tutorials like this.
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/21/2009 4:32 AM
Hi,

I got the following error while compiling this example.

BUILD: [01:0000000049:ERRORE] C:\WINCE600\public\common\sdk\inc\xamlruntime.h(1384) : error C2146: syntax error : missing ';' before identifier 'GestureInfo'

Please advise.
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/21/2009 4:40 AM
To Harsha:
It seems that gestures support is needed by Silvelight for Embedded but it's not included inside your OSDesign as a dependency.
Check that the "Gestures API" element is selected inside the catalog and do a rebuild of your OSDesign.
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/22/2009 1:55 AM
Hi Valter,

Thanks for your response. In the catalog of my OSDesign, Under Shell and User Interface -> User Interface -> Gesture. I checked all 3 options (Gesture Animation Support, Gesture Support for Win32 controls, Single Touch Gesture Recognition). I rebuild the OS succesfully and added the Silverlight Sub project again and I still get the same error that error C2146: syntax error : missing ';' before identifier 'GestureInfo'. I have also checked the option 'Silverlight for Windows Embedded' under User Interface in the catalog.

I am getting the same compilation error. Could suggest how to solve this?
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/22/2009 8:52 AM
The error is due to the fact that the GESTUREINFO struct seems to be undefined.
It's defined inside pwinuser.h and in the tutorial code this file is included just before xamlruntime.h.
Can you check that GESTUREINFO is defined inside your own pwinuser.h file?
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 7:09 PM
Hi Valter
I got the same error, What can I do to fix the error ?
I already check 3 options (Gesture Animation Support, Gesture Support for Win32 controls, Single Touch Gesture Recognition)

May I copy pwinuser.h file in my project file?

thank you
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 7:15 PM
Hi Valter,
I got the same error ,How can I fix it?
I already check 3 options (Gesture Animation Support, Gesture Support for Win32 controls, Single Touch Gesture Recognition). I rebuild the OS succesfully and added the Silverlight Sub project again and I still get the same error that error C2146: syntax error : missing ';' before identifier 'GestureInfo'. I have also checked the option 'Silverlight for Windows Embedded' under User Interface in the catalog.
May I copy pwinuser.h file into my project? thank you~
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/22/2009 7:28 PM
Hi Phill,
did you check if GESTUREINFO is defined inside pwinuser.h?
How did you install R3?
There was a mistake in the instructions and it seemed that you have to re-install QFEs after you installed R3. That is wrong! R3 includes QFE up to September 2009 and you'll have to install only the QFEs that will came out after its release (none right now). If you installed QFEs after R3 you'll have to reinstall it or repair its installation.
If you have GESTUREINFO structure defined inside pwinuser.h under WINCE600\PUBLIC\COMMON\OAK\INC but not under the copy you should have under WINCE600\CESYSGEN\OAK\INC inside your OSDesign you should try to do a clean rebuild of your OSDesign.
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 7:44 PM
HI Valter
I found HGESTUREINFO in pwinuser.h,is it?


Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 7:53 PM
Hi Valter,
I found HGESTUREINFO in the pwinuser.h ,is it?
thank you
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/22/2009 8:06 PM
You found it in the copy under \WINCE600\PUBLIC\COMMON\OAK\INC and also in the one inside your OSDesign?
If you included pwinuser.h before xamlruntime.h (as in the tutorial code) it should work.
Are you still having the problem?
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 8:17 PM
I found pwinuser.h in the \WINCE600\PUBLIC\COMMON\OAK\INC and my OSdesign.

Yes , I am still haveing the problem.
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/22/2009 9:04 PM
I found pwinuser.h in the \WINCE600\PUBLIC\COMMON\OAK\INC and in the my OSDesign

Yes, I still having the problem.

Where can I download QFEs ? thanks.
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/22/2009 11:17 PM
Hello Valter,

It worked! Somehow I had missed pwinuser.h in the code file. I added it and it compiled successfully with no errors.

I am a silverlight(desktop) developer exploring Silverlight on WinCE.

Could you share any link for running the EXE which I have built on Windows CE 6 emulator? I have installed Windows embedded CE6 test kit which comes with Platform Builder.

Thanks a ton for helping me in this.

Harsha
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/22/2009 11:23 PM
To Phill:
I understand that you have found the file in both places.
Now check those points:
1. did you included it inside your source before you included "xamlruntime.h"
2. can you find a definition for GESTUREINFO inside pwinuser.h

Let me know about those points.

To Harsha:

Nice to know that you fixed that problem.
To test your applications on the emulator you need to build an OS image for it. You can do that using platform builder (the test kit is not needed).
You can find many tutorials about how you can build a runtime image for the emulator on www.windowsembedded.com and www.msdn.com/embedded.
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/23/2009 12:50 AM
Hello Valter,

1.I included it inside my source before you included "xamlruntime.h"
2.Yes,I have to do that.
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/25/2009 1:37 PM
Yes , I tried it , but it still have some bug .
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/25/2009 2:28 PM
HI Valter

I have some question
1.unresolved external symbol XamlRuntimeUninitialize referenced in function WinMain
2. unresolved external symbol GetXRApplicationInstance referenced in function
thank you
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/25/2009 6:56 PM
Hi Valter,

I am still unable to run my application. When I chose to run on the emulator, I go to "attach device" after setting it up for an emulator. It downloads the image, and the emulator comes up, but the screen is blank. I think I need to select the Connectivity options properly. This I am not sure. Could you please advise me on this.

Thanks,
Harsha
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/25/2009 8:46 PM
For Phill:
It seems that you solved your previous compilation problem, posting the solution here may help other people...
Now it seems that you didn't add the Silverlight for Embedded libraries to your subproject. You should change the TARGETLIBS directive inside your sources file (right click on your subproject and click Open to edit ti) to:
TARGETLIBS= \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib \ $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\xamlruntime.lib \ $(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\uuid.lib \

for Harsha:
To configure the emulator you should select "Target\Connectivity options..." and choose "device emulator (DMA)" as download and transport and "KdStub" as debugger, then press apply and close.
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/25/2009 9:51 PM
Hi Valter,

I was able to open the emulator, when I try to run the silverlight sample using 'Run Programs' option, nothing happened on the emulator. I have just created a button in blend and imported to the CE Silverlight sample application.

Thanks,
Harsha
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
10/26/2009 1:02 AM
Hi Valter,

It worked for me. I was able to run my first Silverlight for embedded application. Thanks a lot for helping me doing that. :)

Harsha
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
10/28/2009 3:03 AM
Hi Valter,
I can try my first sample in winCE.
but, I don't know how to put my photo or picture to change background.

thank you
Gravatar
# re: Silverlight for Embedded tutorial
ATS26
10/29/2009 9:34 PM
Hi,
i tried this and the compiler works fine. But i have a linker error:
xamlruntime.lib(Application.obj) : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __cdecl RadioButtonGroupManager::RadioButtonGroupManager(void)" (??0RadioButtonGroupManager@@QAA@XZ)" in Funktion ""protected: __cdecl XRApplication::XRApplication(void)" (??0XRApplication@@IAA@XZ)".

There are about 306 error of this kind. I added the xamlruntime.lib but without any success
Gravatar
# re: Silverlight for Embedded tutorial
ATS
10/30/2009 12:43 AM

Hi,
i tried this and the compiler works fine. But i have a linker error:
xamlruntime.lib(Application.obj) : error LNK2019: Verweis auf nicht
aufgelöstes externes Symbol ""public: __cdecl
RadioButtonGroupManager::RadioButtonGroupManager(void)"
(??0RadioButtonGroupManager@@QAA@XZ)" in Funktion ""protected: __cdecl
XRApplication::XRApplication(void)" (??0XRApplication@@IAA@XZ)".
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/30/2009 12:57 AM
To Phill:
you can include an Image object inside your silverlight page and use its SetSource method to load an image at runtime.

To ATS:
Are you trying to build the tutorial code by downloading the project from here?
Gravatar
# re: Silverlight for Embedded tutorial
ATS
10/30/2009 1:48 AM
Hi Walter,

its always the same. when i don't include the "xamlruntime.lib" i get this linker errors:
1>SilverlightSample.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "GetXRApplicationInstance" in Funktion "WinMain".
1>SilverlightSample.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol "XamlRuntimeInitialize" in Funktion "WinMain".

and when i add the "xamlruntime.lib" i get the one i previously discribed.

and sorry for posting my problem twice
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
10/30/2009 5:40 AM
It seems that something is missing inside xamlruntime.lib (the missing link is referenced from the library and it's not something declared inside the demo app source code).
How big it is your current xamlruntime.lib? On wich platform?
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
11/1/2009 3:42 PM
Hi Valter,
I have a problem ,I can put my background in page.xaml ,but I can not show my background in winCE . How can I do ?
Gravatar
# re: Silverlight for Embedded tutorial
ATS
11/1/2009 9:00 PM
I'm using the ARMV4I platform. My xamlruntime.lib is about 29mb respectivly 34,5mb (debug) big. I included the follow libpaths:
C:\WINCE600\PUBLIC\COMMON\SDK\LIB\ARMV4I\RETAIL
C:\WINCE600\PUBLIC\COMMON\OAK\LIB\ARMV4I\RETAIL
and this includepaths:
C:\WINCE600\PUBLIC\COMMON\SDK\INC
C:\WINCE600\PUBLIC\COMMON\OAK\INC
Gravatar
# re: Silverlight for Embedded tutorial
ATS
11/2/2009 3:05 AM
Hi, i'm using the ARMV4I platform. My xamlruntime.lib is about 29mb respectivly 34,5mb (debug) big. I include the following paths:
C:\WINCE600\PUBLIC\COMMON\SDK\INC
C:\WINCE600\PUBLIC\COMMON\OAK\INC
C:\WINCE600\OTHERS\ATL8\INCLUDE
C:\Programme\Windows CE Tools\wce600\PicoMOD4 Core\Include\Armv4i (my controler)
and this libpaths:
C:\WINCE600\PUBLIC\COMMON\SDK\LIB\ARMV4I\DEBUG
C:\WINCE600\PUBLIC\COMMON\OAK\LIB\ARMV4I\DEBUG
C:\Programme\Windows CE Tools\wce600\PicoMOD4 Core\Lib\ARMV4I

maybe this can help


Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
11/3/2009 9:07 PM
Sorry for replying so late but I got some problems with comment notification e-mails.

To PHILL_LIU:
Did you copy your bitmap to the device?
You can use SetSource method of the IXRImage object to specify its URL (local file path). You can get an IXRImagePtr object using the FindName method, like we did in the tutorial for the button. Remember that you have to set a name for your device inside the XAML file!

To ATS:
runtime library size seems to be correct.
Are you building the code inside VS2005 or VS2008 (it seems that you are linking an SDK)?
Did you try to build it as a subproject?
Gravatar
# re: Silverlight for Embedded tutorial
Harsha
11/4/2009 11:27 PM
Hi Valter,

Are there any custom controls available for Silverlight embedded? Also I have to add a DLL reference to the Silverlight WE subproject. Could you pls tell how do I do that?
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
11/4/2009 11:35 PM
To Harsha:
I don't know about custom controls available for Silverlight for Embedded. The technology has been release less than two months ago and you can't port a "regular" Silverlight control by simply re-building it, so I suppose that it will take some time before we will see some control libraries for the embeedded version.
To add a DLL that has an export library (a .lib file) you can simply add a reference to the lib file (not the DLL) to the TARGETLIBS entry of your sources file. Library paths should be separated by spaces and you can start a new line by adding a backslash as the last character of the previous line.
If you don't have a .lib file you need to link the DLL at runtime using LoadLibrary and GetProcAddress.
Gravatar
# re: Silverlight for Embedded tutorial
Justin Mitchell
11/6/2009 7:45 AM
"You may develop your Silverlight for Embedded application also using Visual Studio 2005 or 2008 Smart Device application if you generate an SDK from your R3 OS design and install it on your development PC" How do you do this?
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
11/7/2009 4:16 AM
To Justin:
You can export your SDK from platform builder.
After you created an OS Design that includes the Silverlight for Embedded runtime you can then select "Project\Add new SDK...". A wizard will allow you to configure the SDK, adding also the emulator image to it.
Then you can select your SDK in solution explorer, right click on it and choose "Build SDK" to generate an MSI file that you can install on any PC with VS2005 or 2008.
Gravatar
# re: Silverlight for Embedded tutorial
Eddy
11/10/2009 6:01 PM
Hi Valter,

As you mentioned about QFE, R3 includes QFE upto Sep.2009.
you mean that only required further QFE is from October.2009 after R3 installed ?
Gravatar
# re: Silverlight for Embedded tutorial
Valter Minute
11/10/2009 8:40 PM
To Eddy:
Yes, you should install only QFEs that has been released after R3.
In some of the readme files you'll find some misleading instruction that seem to suggest that you have to install all the QFEs that are available on ms website (2008 cumulative and a QFE for each mont in 2009), but that is not correct.
If you installed those QFEs you can relauch R3 setup and choose "repair" to restore a working build environment.
Remember also that yearly QFEs include all the previous updates (up to the end of the year) but monthly QFEs don't so if you need to install a monthly QFE to solve a problem you experienced on your device you should install the last cumulative QFE (and R3 is a cumulative QFE up to september 2009) and then all the monthly QFEs released before the one that interests you.
Gravatar
# re: Silverlight for Embedded tutorial
Raymond
11/12/2009 5:46 AM
Hi, Valter
This is trully an excited new toy. I can make the sample code run. But I meet a problem when I tried to put a image in the page. Can you add a image control in your sample code? The problem is that we can not setup build options to a image file like we did in C# project. But, without set these options, the source properti of the image is empty. I can not bind a jpg image file to the image control.
Please help.
Thanks,
Gravatar
# re: Silverlight for Embedded tutorial
PHILL_LIU
11/14/2009 8:33 PM
Hi Valter,
I want to design three button , they can show different messagebox ,I had to see your another example,but I don't know how to differentiate messagebox in code.

Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
11/18/2009 7:13 PM
To Raymond:
You can find an example of using images inside the third step of the tutorial that I've just published here:
http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/11/18/silverlight-for-windows-embedded-tutorial-step-3.aspx

To Phill:
You can simply have three event handlers each one showing its own message or you may use the source argument passed to the OnClick event handler to recognize the button sending the Click event.
If you use XAML2CPP (http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/11/11/xaml2cpp.aspx) you can set a name for the buttons and their event handlers and let the utility generate most of the code for you.
Gravatar
# re: Silverlight for Windows Embedded tutorial
PHILL_LIU
11/19/2009 11:05 PM
HI Valter,

I have a problem of storyboard , I want to contorl the button , That button can move up and down , I used two storyboard to control it
,but the button can not move to same space .
What can I do ? Thanks
Gravatar
# re: Silverlight for Windows Embedded tutorial
lz
12/3/2009 3:24 PM
Hi,Valter!
I just cannot install Exression Blend 2 SP1 which I download from Microsoft's website.Where can I get a avalible one?Thank you!
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
12/15/2009 12:55 AM
To Phill:
Can you post some sample code to understand your problem?

To Thomas:
Working on it, it will be the subject of the next tutorial step, I hope. But I'm looking for a way to integrate listbox management inside code generated by XAML2CPP without adding too much overhead and unnecessary code to the base classes.

To lz:
The only place from where you can download Expression Blend 2 and SP1 is microsoft website. Check that the files you downloaded are not truncated and post the error message you get when you try to install them.
Gravatar
# re: Silverlight for Windows Embedded tutorial
George
1/25/2010 11:13 AM
Great Introduction. I found that I had added the Includes= statement just before the TARGETLIBS and this caused a small cascade of problems. Examining your source code however put me on the right track. I moved the Includes to the end of the sources file and life is good!

Thanks Again..
Gravatar
# Smart Device Project
Justin Mitchell
3/11/2010 4:01 AM
I have exported and installed my SDK. I can emulate projects on it and everything. My problem is I can not figure out how to create a Silverlight for Embedded Smart Device Project from Visual Studio so that I can emulate it on my device. How can I do this?
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
3/11/2010 4:13 AM
Ciao Justin,
there is no "Silverlight for Windows Embedded" template in Visual Studio, you should just create a regular Smart Device application and add the references to the the Silverlight for Windows Embedded libraries to it (xamlruntime.lib,uuid.lib). If the compiler can't find some include files you may need to add your WINCE600\PUBLIC\COMMON\OAK\INC dir to the include path or (better) add them to your SDK.
You can also build Silverlight for Windows Embedded applications as Platform Builder subprojects, as I do in this tutorial.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Gomathy
4/13/2010 11:26 PM
Hi,
Please provide me an example to switch to next window on button click in silverlight for windows embedded.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
4/28/2010 11:18 PM
Ciao Gomathy,
I'll try to put this in one of the next steps of the tutorial.
You can basically do that in two ways:
close and re-create a new windows (by reloading a different XAML and creating a new visual host) or by putting all your windows contents in different panels inside the same XAML cointainer and hiding/showing them when needed.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Abhineet Agarwal
5/5/2010 10:31 PM
Hi Valter

I have created one xaml which consists of 4 buttons. On click of every button. I have to open a different exe files. I was able to do for one button by the above concept mentioned in your tutorial but how should i do for multiple buttons.
Please explain me.

Thanks in Advance.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Rabiammal
5/6/2010 8:45 PM
Hi Valter,
Can you please provide me some sample code for retrieving the items present in the ComboBox?
GetSelectedItem member function for IXRComboBox class takes the argument of IXRDependencyObject Class. How to pass this argument and print the selected item in the comboBox.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
5/10/2010 1:39 AM
@Abhineet Agarwal
You can implement a different event handler for each button or use the source argument passed to the event handler to understand which button has generated the event.

@Rabiammal
GetSelectedItem will return a pointer to a Silverlight object. You should then retrieve information from that object. See the listbox sample in the tutorial to understand how to implement it.
Gravatar
# CreateHostFromXaml error
Carlo
5/14/2010 2:40 AM
Hi Valter,
I created your tutorial and downloaded it to the simulator.
The program exits when it executes the "CreateHostFromXaml" function... :(
I'm using the code downloaded from this web site.
Thank you!
Ciao, Carlo.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Rabiammal
5/17/2010 10:10 PM
Hi Valter,
thanks for your kind reply.
I have solved the ComboBox issue by getting the index of the item, and by using the index , i have retrieved the value.
MAny times ,Iam getting error as below:
"
Abort' (4): Thread-Id=0559000a(pth=8d9a8774), Proc-Id=0540000a(pprc=8d9a85b8) '
AFM_GUI.EXE', VM-active=0540000a(pprc=8d9a85b8) 'AFM_GUI.EXE'
PC=40213450(hgcore.dll+0x00143450) RA=402133dc(hgcore.dll+0x001433dc) SP=0004f8e
0, BVA=3f800018
Exception 'Raised Exception' (-1): Thread-Id=0559000a(pth=8d9a8774), Proc-Id=004
00002(pprc=8a133308) 'NK.EXE', VM-active=0540000a(pprc=8d9a85b8) 'AFM_GUI.EXE'
PC=c003bc28(k.coredll.dll+0x0001bc28) RA=883144c8(kernel.dll+0x000064c8) SP=d533
f4a0, BVA=ffffffff"
As far as i know, i think hgcore.dll is a new DLL which is added in R3,
Is there any relation between SilverLight and this hgcore.dll?
If, I click the application, other than the area where the controls are not there, then exception comes.
Is there anything to be handled in the Event Controller ?
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
5/27/2010 10:57 PM
@Carlo
Did you try to download the code from the website?
If you try with a debug image you may receive some more information about the error on the debug output.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Girish
6/4/2010 11:20 PM
Hello Valter,
You have a very detailed post. Thanks.
I tried the exact steps that you have mentioned. Everything compiles properly. I am testing the Silverlight Sample app by running it on an Actual Win CE 6.0 device. However, it does not run at all. No errors/exceptions either.
Any pointers would be really helpful. Thanks.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Velraja
6/8/2010 9:30 PM
Hi Valter,
Your tutorial was very useful to understand Silverlight for WCE and Windows CE.
But,now I am struggling to create child window when click a button in primary window.Please help me
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
6/14/2010 10:37 PM
@Girish
Could you try to execute your code step-by-step and check where it fails?
It may be that the XAML code is not correctly include in the resources or that your OS image is missing some components needed to run the sample.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
6/14/2010 10:38 PM
@Girish
Could you try to execute your code step-by-step and check where it fails?
It may be that the XAML code is not correctly include in the resources or that your OS image is missing some components needed to run the sample.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
6/14/2010 10:44 PM
@Velraja
You can create a new page following the same operation sequence used in the WinMain to create the main window.
Using CreateHostFromXaml you can load a new XAML object and create a Window that could be activated using ShowDialog.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
6/14/2010 10:44 PM
@Velraja
You can create a new page following the same operation sequence used in the WinMain to create the main window.
Using CreateHostFromXaml you can load a new XAML object and create a Window that could be activated using ShowDialog.
Gravatar
# re: Silverlight for Windows Embedded tutorial
George
6/22/2010 4:45 AM
I manage to solve the "the pwinuser.h" could not be found problem by double clicking on the subproject and including
INCLUDES=$(_OEMINCPATH) line
and
TARGETLIBS= \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\coredll.lib \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\xamlruntime.lib \
$(_PROJECTROOT)\cesysgen\sdk\lib\$(_CPUINDPATH)\uuid.lib \

If I want to create a silverlight application
outside the OS design how can I do it?
I created and sdk and installed it but when I
tried to build the silverlight app I had again the missing pwinuser.h file problem. How can
I include this file in the sdk?
What I did was to left click on the SDk and go
to properties. I selected additional folder and added
Source:
C:\WINCE600\OSDesigns\AT91Sam9263_SRC_Test\AT91Sam9263_SRC_Test\Wince600\AT91SAM9263EK_ARMV4I\cesysgen\oak\inc

Target
Include\ARMV4I

and

Source:
C:\WINCE600\OSDesigns\AT91Sam9263_SRC_Test\AT91Sam9263_SRC_Test\Wince600\AT91SAM9263EK_ARMV4I\cesysgen\oak\lib

Target:
LIb\ARMV4I

The pwinuser.h was included in the sdk but
I get a linker error "Error 1 error LNK2019: unresolved external symbol XamlRuntimeInitialize referenced in function WinMain Silverlight_Test1.obj Silverlight_Test1
"
What you think might be the problem did I include the wrong directories? How can I include pwinuser.h in my SDK?

Thank you in advance
Gravatar
# re: Silverlight for Windows Embedded tutorial
Alex Krush
7/10/2010 11:29 PM
Hi Valter,
I'm beginner with CE development. I created the helloWorld app as a subproject of my custom OS Image and deployed it with Win CE Remote file Viewer (by the way, what's the best way to deploy it?). It works fine.
Could you explain please, how to create an new application based on SDK created from my OS Image.
I can create an new win32 C++ Smart Device Project, in the the step 2 I can choose my platform. But what I need to do next?
My goal is to work in a new copy of VS to make is easy to debug and deploy my app against running OS image in ARM4 emulator.
Many thanks in advance,
Alex
Gravatar
# # Load XAML dynamically
Azhar
7/14/2010 3:16 AM
please can you give me any hind, that How I can render a new XAML dynamically in the Click event of the Button...I have 2 Xaml, one is as the Base Xaml and other i want to re-render in the click event of the button.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Gomathy
7/19/2010 12:53 AM
Hi Valter,

Thanks. I have one more Query.Silverlight for windows embedded does not support extended controls, but i need calendar and tab control. How to implement in WinCE6.0?

Thanks in Advance.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Igor
7/19/2010 11:07 PM
Hello, Valter!
Thanks for the tutorial, it's really helpful!
I repeated this lesson step by step and it compiled and linked well. But it would not run as app->CreateHostFromXaml() fails. I discovered that it happens because resources are not embedded into executable file (for the experiment, I tried to embed version info into executable and it didn't work) and CreateHostFromXaml() simply can't find xaml code. How can I make Platform Builder to embed XAML resource into executable?
Gravatar
# re: Silverlight for Windows Embedded tutorial
Igor
7/19/2010 11:21 PM
Hello Valter!
Platform Builder didn't embed resources into executable because I added the .rc file to "Resource files" folder in the project, not to "Source files" as I had to. In the sources file of the project this file must be added to SOURCES= directive.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Urmik
7/21/2010 10:34 PM
Hi valter
I want make applications for Windows CE..i am going to use Windows CE R3 for that..Could you please tell me how can I get or how can i make application or Portable navigation device with attractive style UI like Vista or Windows 7...Is there only one option "Silverlight" for attractive GUI or is there another option??
Gravatar
# re: Silverlight for Windows Embedded tutorial
Velraja
7/23/2010 1:52 AM
I have created a simple sub-project...
application run in emulator screen...But window does not appearing in screen...In taskbar window title is showing....
Gravatar
# re: Silverlight for Windows Embedded tutorial
Gomathy
7/27/2010 12:21 AM
Hi Valter,
How can i use calendar control in silverlight for windows embedded?It is not supporting the extended controls.


Thanks in Advance
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:16 PM
@Gomathy
To handle a calendar you should implement your own custom control (following the example that you'll find in my tutorial).
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:22 PM
@Igor
Yes, you are right. The rc file is a source file, the "resources files" folder should be used for external files like bitmaps, icons etc.
PB UI can be misleading and let you think that everything resource-related should go inside that folder.
Thank you for pointing that out
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:28 PM
@Urmik
Silverlight for Windows Embedded is the easiest way to create rich UIs from scratch but on Windows CE you can also customize the standard windows UI to look more like Vista or Windows7 by creating your own GWES controls rendering library.
The Windows XP-like "skin" in PB is a good sample of this kind of customization.
In this way you can still use standard Win32 controls but having them rendered on screen trough your own code.
You can find some more information about this kind of customization here:
http://msdn.microsoft.com/en-US/library/ee500211.aspx
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:30 PM
@Velraya
Check that your Window parameters have been configured correctly trough the XRWindowCreateParams struct.
If you have the button in the system tray and no window on the screen it may have been created out of the screen.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:50 PM
@Alex
If you created your app as a PB subproject it should be already in the OS Image, unless you choosed to exclude it using the PBXML options dialog.
Even in this case, if you are connected via KITL you can execute your application using the target\run programs... menu entry. The exe will be loaded from the \Release folder.
To develop using VS2005 you should generate an SDK for your device that will include all the libs and header required by Silverlight for Windows Embedded but one single header (pwinfuncs.h) that you should copy from your WINCE600 folder.
You can develop your Silverlight for Windows Embedded application as a regular app and debugging it using the Visual Studio remote debugger:
http://geekswithblogs.net/WindowsEmbeddedCookbook/archive/2009/06/12/visual-studio-application-debugger.aspx
Gravatar
# re: Silverlight for Windows Embedded tutorial
Valter Minute
8/9/2010 7:53 PM
@George
You include the header and libs in the SDK successfully.
You just need to add a reference to xamlruntime.lib to your linker input options.
Gravatar
# re: Silverlight for Windows Embedded tutorial
toplum
8/21/2010 1:27 AM
sure hope inplace will be possible. lots of customers want that.
Gravatar
# re: Silverlight for Windows Embedded tutorial
chiranjeevi
9/15/2010 6:07 PM
hi thnx for ur tutorial,

i need to develop one sample demo, which has to naviagte to various pages in silverlight for windows embedded.
is there nay sample available please do the needfull
Gravatar
# re: Silverlight for Windows Embedded tutorial
Andre Natal
11/15/2010 9:22 AM
Can we the pageflip control with silverlight for embedded?
Gravatar
# re: Silverlight for Windows Embedded tutorial
Reconquerir Ex
12/16/2010 6:32 AM
I am curious to find out what blog platform you happen to be working with? I'm experiencing some minor security issues with my latest blog and I would like to find something more safe. Do you have any suggestions?
Gravatar
# re: Silverlight for Windows Embedded tutorial
Nathaniel
1/6/2011 12:57 AM
Hi Valter,

thank you very much for your post, this info was very useful since it is inexistent on the net.
Still, I have some difficulties to understand how the whole thing is functioning together.

1) I finally managed to open the emulator by building my own SDK as you explained above. So the windows CE 6.0 appears. But after this I am unable to find the button application. Where is it?
The fact that our application is a subproject in VS, is supposed to integrate it automatically in the OS right?

2) Another question, can you please explain or send me a link that explains the role of all this C++ code here. I have understood that it is a kind of gap between the XAML code and our OS design. Is this right or am I definitely out of the picture?

3) Another question I want to ask is about the applications which will be called from the UI (created with expression blend), do they necessarily have to be written in C++?

That's what I'm wondering for the moment. Thank you very much for your help or anyone's help...

Nathaniel

Gravatar
# re: Silverlight for Windows Embedded tutorial
Nathaniel
1/8/2011 10:08 PM
Hi,

Thanks for useful tutorials.
I am very very beginner in the whole things, and in order to understand all the code we have to write, I wanted to know more about this C++. Because it does not really look like regular C++, but C++ related to windows. Could anyone address me to a good tutorial in order to learn this?

Thank you,
Nathaniel
Gravatar
# re: Silverlight for Windows Embedded tutorial
Cesar Mello
2/16/2011 2:49 PM
Very nice tutorial. Congratulations, best regards! Mello. Nathaniel: Try Charles Petzold's Windows programming book and an introductory book about COM.
Gravatar
# re: Silverlight for Windows Embedded tutorial
Cesar Mello
2/17/2011 1:13 AM
Here is another nice Windows programming tutorial: http://msdn.microsoft.com/en-us/library/ff381399(VS.85).aspx
Gravatar
# re: Silverlight for Windows Embedded tutorial
Kevin Krüger
9/24/2012 3:34 AM
I did not read all comments so I do not know if this Solution is already posted...

If you have an SDK only you can not apply the last step because your "sources" File is missing.

Instead you have to link against the Libraries manually using the Project properies.

Therefore click your Sub-Project properties and select Linker -> Input and choose "Additional Dependencies". In the top Textarea you just enter the names of the libraries to link against (xamlruntime.lib uuid.lib) separated by a new line character (enter)

This should enable you to build Silverlight Application without using the Platform Builder.

Post Comment

Title *
Name *
Email
Comment *  
 
Toradex logo

Tag Cloud