Solibulo

Uninteresting things

Bug with Blend 3 RC and sample data

by softlion 25. July 2009 12:26

 

This has been fixed in RTM version : in the "build action" property of all files which are in the SampleData folder a "DesignTimeOnly" value is set so sample data is no compiled in your release project (if you unticked the "Enable when running Application" choice in the datasource property in Blend 3).

 

Update: it is not fixed at all ! The .cs file is still set to "compile" (as the referenced sample data is still in app.xaml this makes sense). This workaround is still needed.

 

In Blend 3 there is a userful feature called sample data which helps design UIs binded to data not currently existing.

 

When using this feature, blend adds a “SampleData” folder in your silverlight project, and new XAML files with their associated codebehind (.xaml.cs). It also modifies your App.xaml to reference the sample data class and creates a new global instance of this xaml.

 

When switching to release mode, your xap file will grow bigger than needed. So in the xaml.cs file there is a conditional compilation symbol which can be define in ‘project/properties/build’ tab to minimize the content of the cs file: DISABLE_SAMPLE_DATA

 

The default .xaml.cs generated by blend 3 contains :

 

#if DISABLE_SAMPLE_DATA
    internal class BoardInfosDataSource { }
#else

 

But when in release mode, the compiler removes all non public unused objects. And your silverlight application will throw an errror (if you use asp:Silverlight you won’t see the error just a blank screen. Use the object tag with onerror set to your javascript instead. See MSDN for more infos.).

 

To correct this set the class public:

 

#if DISABLE_SAMPLE_DATA
    public class BoardInfosDataSource { }
#else

 

Tags: