Wednesday, June 30, 2010

Silverlight Toolkit Theme Controls

I downloaded the Silverlight toolkit from http://silverlight.codeplex.com/releases/view/43528 (Silverlight_4_Toolkit_April_2010.msi). When I ran the msi, and subsequently opened Visual studio 2010, in the toolbox under the tab "All Silverlight Controls" I found several "Theme Controls" such as BubbleCremeTheme, RainierOrangeTheme etc.

These can be used as controls rather easily. For example, open a new Silverlight application. On MainPage.xaml select a theme control from the toolbox and drag it onto the design surface. This causes a reference to be added to the Silverlight project for the associated theme control (System.Windows.Controls.Theming.BubbleCreme).

I used the XAML tab to get the xaml to look like the following:

<grid name="LayoutRoot" background="White">
<?xml:namespace prefix = toolkit />
<toolkit:bubblecremetheme name="BubbleCremeTheme1">
<toolkit:bubblecremetheme.content>
</toolkit:bubblecremetheme.content>
</toolkit:bubblecremetheme>
</grid>

I added some controls to <toolkit:bubblecremetheme.content>. An example follows:

<grid name="LayoutRoot" background="White">
<toolkit:bubblecremetheme name="BubbleCremeTheme1">
<toolkit:bubblecremetheme.content>
<grid>
<button name="Button1" type="submit" content="Button" height="23" horizontalalignment="Left" margin="56,30,0,0" verticalalignment="Top" width="75">
<checkbox content="CheckBox" name="CheckBox1" height="16" horizontalalignment="Left" margin="58,62,0,0" verticalalignment="Top">
</grid>
</toolkit:bubblecremetheme.content>
</toolkit:bubblecremetheme>
</grid>

The themes are encapsulated in the associated control (System.Windows.Controls.Theming.BubbleCreme) - they should be treated like any other control when used. During my experimentation I had to switch between design and xaml views in Visual Studio 2010 to get the xaml just right.

Xaml source for the themes are available and can be found at the installation path for the Silverlight 4.0 toolkit: (on my Windows 7 64 bit machine: C:\Program Files (x86)\Microsoft SDKs\Silverlight\v4.0\Toolkit\Apr10\Themes\Xaml)

Friday, June 25, 2010

ODATA

After attending the OData roadshow in Chicago a few weeks ago I have been inspired to learn and practice OData. After some absence from the blogging world, I decided to write some entries about my experiences.

My very first comment about OData--it is awesome, exposing data with ease, improving and streamlining application development.

I also have done some work with RIA (domain services). During my learning cycle I found that a RIA domain service can also be exposed as Odata. When creating the domain service be sure to check "Expose OData endpoint" check box.

Then through the browser you can access the domain service as an odata endpoint.

It took me awhile to actually get this to work, as most of my problems were syntax related.

Here is what I learned: to access an OData endpoint that is a RIA domain service in a Silverlight project (4.0) the following should work:

If your Silverlight Web project is named: SilverlightApplicationSimpleRIA.Web

Then the link to access the OData endpoint is:
http://localhost:2551/SilverlightApplicationSimpleRIA-Web-DomainServiceNW_RIA.svc/OData/

Notice
1) . (period) is replaced with a - (In web project name)

2) appended to the project name SilverlightApplicationSimpleRIA-Web is a - and then the name of the Domain Service (as defined in the Web project), followed by .svc, followed by a /
i.e. SilverlightApplicationSimpleRIA-Web-DomainServiceNW_RIA.svc/
Be aware that the "silverlight web" project has no .svc file defined, this is constructed "virtually" for a domain service

3) then add OData/ (the syntax here caused me a bit of a problem--OData is case sensitive -- also do not forget the ending / (if you do you'll probably get endpoint not found message when doing the access)

I tested this with IE 8 along with Silverlight 4, and it worked like a champ.