Silverlight 4: ChildWindow

One of my favorite features of SL 4 is the childwindow. You can add a window to your project just like in WPF and then add all the xaml to it. Then define it in your code. For instance, the following code references a childwindow called ItemMaintenance. Its creates a new instance of it, then wires up a closed event, then shows the window. (more…)

Silverlight 4: Datagrid

Today i am building features using the new Datagrid for SL 4. Pretty cool.
I wanted to be able to set the column widths and headers magically in code. So i added names to the column headers like so:

(more…)

VS2010 Silverlight:Bug with XAML Files and code behind

I have a bug that has been recurring with some frequency during the RC cycle of VS 2010 and its still there in the RTM.Lets say I have a SL usercontrol with several fields on it. All of a sudden the usercontrol gets in a state where the code behind cannot see the fields in the XAML. If you try and specify the fields in code, intellisense does not work and typing the field name generates an error.

(more…)

Silverlight: xap caching in IIS

Today i was having a problem where my SL app was not updating. Looked at the IIS settings and finally stumbled on Output Caching. To see if this would work, i added a rule for .xap files to chache until the file changed. Now IIS looks like so for caching:

(more…)

Silverlight: Design Time support for controls

When you are creating custom controls, always add attributes for their properties so the controls are categorized the way you want them. For instanced, the following attributes add a new category called MyCustomer.app to the property designers in Visual Studio and Blend. Now my properties show up under the MyCustomer.app category: (more…)

Silverlight: Merged dictionaries

If you need to change a resource dictionary its easy to swap them out. I like to define the dictionary in XAML (App.xaml) like so:

<ResourceDictionary>
 <ResourceDictionary.MergedDictionaries>
 <ResourceDictionary Source="BlueResourceDictionary.xaml"/>
 </ResourceDictionary.MergedDictionaries>
 </ResourceDictionary>

(more…)