Silverlight Archives - Digital Tool Factory blog Silverlight Archives - Digital Tool Factory blog

The Digital Tool Factory Blog

Silverlight Tip – How to make bold text in a textblock from the CodeBehind

The Problem: You need to conditionally bold text in a text block, but you cannot find any way of doing so

The Cause: For inexplicable reasons, Microsoft chose not to include a FontWeight.Bold in their xaml specification

The Solution: Microsoft did include a FontWeights (note the S) class  To bold text in the codebehind, all you have to do is write this

tbbDownloader.FontWeight = FontWeights.Bold;

And presto!  Bold Text.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


27
Jul 10


Written By Steve French

 

How to fix updating problems in your Silverlight application

The Problem: You make changes to your Silverlight Application, but you do not see it reflected when you debug or run the solution.2cv_phil_repair_small

The Cause: While the web project portion of the solution is being compiled and run, the Silverlight project is not being built.  This just happened to me recently.  Visual Studio crashed and somehow the Silverlight project portion of the solution decided to remove itself from the build list.

The Solution: Right-Click on the solution, then select “Configuration manager”.  Make sure that the “Build” checkbox is selected for both projects.  That’s it!

Creative Commons License photo credit: Mooganic

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


02
Mar 10


Written By Steve French

 

How to fix strange errors in silverlight web services

fix you_smallThe Problem: You upload your wonderful Silverlight application to a new server and begin to get all sorts of strange errors, most notably something like this

Message: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at StronicoMain.ServerUtil.AddressTypeListCompletedEventArgs.get_Result()
at StronicoMain.Page.proxy_AddressTypeListCompleted(Object sender, AddressTypeListCompletedEventArgs e)
at StronicoMain.ServerUtil.ServerUtilClient.OnAddressTypeListCompleted(Object state)
Line: 1
Char: 1
Code: 0
URI: http://www.servername.com/Silverlight.js

Continue reading →


02
Mar 10


Written By Steve French

 

How to fix margins in silverlight

The Problem: You try to set margins the same way in xaml as in xhtml/css.

The Cause:
The margin property in xaml is different than the margin in xhtml/css

The Solution:
Use this bit of info: the margins in xaml go left,top,right,bottom, or clockwise from 9:00.

This was hardly the most significant problem I had with the new app, but it did take me a little while to figure out, so I thought I would blog it in case someone else had the same problem.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


25
Oct 09


Written By Steve French

 

How to fix “Value does not fall within the expected range” error in Silverlight

The Problem: Your code goes about it’s merry way, adding children to parents and so forth when you get the error

Value does not fall within the expected range

The Cause: The problem is caused by two objects having the same name in the same parent. If your canvas has two StackPanels named “spOverlap” then this error is thrown. Why the error message couldn’t just say “Duplicate Name Error” no one knows. I’ve encountered this error when dynamically adding controls to the application.

The Solution (Part 1): The simple way to fix it is to simply name the newly added control with a guid or a ID number of some sort.

The Cause (Part 2): I did in fact do that, and then encountered another error, namely that things were expanding exponentially.

Here’s the situation. I have a main control (call it StronScreen), which will spawn a child control (call it StronTab), which has an event (call it StronEntityAdd) that will add a control (call it StronEntity) to StronScreen. I was adding the event to StronTab every time I spawned it, which meant that there were multiple events attached to StronTab as the user went through the application. It worked fine the first time, by which I mean that it added a single instance of StronEntity to StronScreen. The next time I spawned StronTab (this is a necessary and desirable feature of the application) and call StronEntityAdd TWO instances of StronEntity would be added to StronScreen.

The Solution (Part 2): Create the event handler as null when the page is loaded, and when StronTab is called, check to see if the event is null, and if it is, add it to StronTab. If the event handler is not null, then simply don’t add it.

A hard problem to diagnose, and the application does have to work that way, but that fixes it.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


24
Oct 09


Written By Steve French

 

How to solve Unhandled Error in Silverlight Application Code: 2104

I’ve found that I get this error every time I upload a Silverlight application to a new webserver. IIS does not have the correct settings by default.

The Problem: You ftp a Silverlight App to an IIS website, go to the website in a browser, and get the following error:

Message: Unhandled Error in Silverlight Application
Code: 2104
Category: InitializeError
Message: Could not download the Silverlight application. Check web server settings

The Cause: The Silverlight Mime types (.xaml, .xap and .xbap) are not listed in that websites registered mime types, therefore IIS will not send those files to the browser.

The Solution: Open IIS on the server, go to HTTP headers, click on Mime Types, click “Add New” and add the following:

Extension – Mime Type
.xaml – application/xaml+xml
.xap – application/x-silverlight-app
.xbap – application/x-ms-xbap

Hit Apply and your application will load!

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


23
Oct 09


Written By Steve French

 

Silverlight Data validation problems

So – I spent today making one last ditch effort to get the built-in Silverlight data validation to work in my project, all to no avail. I even posted a question on Stack Overflow, and have yet to receive an answer, which is a first for me. I downloaded several of the samples, from Wildermuth, Liberty and others, and they none of them would work out of the box, they all either had strange dependencies or would throw errors on build. I finally gave up and did the validation manually, the most recent version is on the site now. Granted, I’m trying to do remote data objects, so my situation and the examples are a bit different, but it would be nice to have some degree of success with this.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


14
Sep 09


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.