If a user attempts to install a SLOOB app when it is already installed an InvalidOperationException
is thrown with the message "Application is already installed.". We can wrap in a try..catch to handle this:
try
{
Application.Current.Install();
}
catch (InvalidOperationException ex)
{
MessageBox.Show(ex.Message);
}
Or better yet, remove the install button from the UI if the application is already installed:
if (Application.Current.InstallState == InstallState.Installed)
btnInstall.Visibility = Visibility.Collapsed;
else
btnInstall.Visibility = Visibility.Visible;
SHARE:
When running a Silverlight 3 application out of browser (OOB) {or SLOOB=Silverlight Out Of Browser} you can enable the automatic download\install of updated versions.
This is not an automatic feature and requires some (simple) coding on the developers part.
In the App.xaml.cs add a callback for the CheckAndDownloadUpdateCompleted event (the example below uses a lambda but you could use a separate method with the signature void App_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
.
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
// Add callback to be executed when the check (and possible download) has been performed
this.CheckAndDownloadUpdateCompleted += (sender, e) =>
{
if (e.UpdateAvailable)
MessageBox.Show("Update downloaded, plese restart to take effect.");
};
InitializeComponent();
}
Next add a call to check for updates, this can be placed in the Application Startup event handler or you could have a "Check for updates" button in th U.
private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = new MainPage();
this.CheckAndDownloadUpdateAsync();
}
Now, every time the app start an update check will be performed, and if there is an updated version available it will be downloaded asynchronously. Once download the user will get the message box advising them to restart the app to start using the new version. The download\update just happens if available and there is currently no mechanism to allow the user to opt-out of an update.
SHARE:
This is pleasantly simple to do :)
In response to a user action (clicking a button, etc.) add the following code: Application.Current.Install();
e.g.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
Application.Current.Install();
}
Configure the application to run out of browser (OOB):
In the project properties page, tick the"Enable running application out of the browser"

The Out-Of-Browser Settings button now becomes enabled: this lets you specify OOB window and shortcut names, description, and an application icon in 4 different sizes.
You can un-install an OOB app by running it (from the desktop or programs menu) and right-clicking and choosing "Remove this application".
SHARE:
I'm working on a Silverlight media player like you get on MySpace and other sites. The app is meant to be as simple as possible, so i've created a Silverlight-enabled WCF service which returns a list of the MP3s available in the songs directory on the server. To allow the SL app to be as loosely coupled to the location of the physical mp3s, the wcf service needs to return a list of fully qualified URIs to each mp3 in the directory. When the user selects a song to listen to we can simply set the MediaElement.Source to the URI.
The following post contains some great code (that can even be used outside of a WebForm) to convert "~/myfolder/mysubfolder" to http://foo.bar/myfolder/mysubfolder".
http://stackoverflow.com/questions/121962/determine-sites-absolute-fully-qualified-url-in-asp-net
SHARE:
The first version of my Silverlight scale\chord finder is complete, it can be found at http://www.dontcodetired.com/live/silverkeys/
I'd like to improve the UX around the scale degrees, perhaps a circle of scale degrees...(I also have some TODO:s to do around refactoring)
I'll be posting source eventually in addition to an explanation of some of the more interesting elements..
SHARE:
The UI (or should I say UX now?) is 90% complete (for this iteration that is) as the image below shows. There are a few bug fixes left to complete, plus I'd like to to some moderate re-factoring of both the 'business' logic and the XAML.
I'll post some of the more interesting aspects of the project in later posts and either make the source available from here or I might look at uploading to Codeplex et al so others can go ahead and take it forward if it's found to be interesting. There also be a 'live' version available. I'll be using it personally to try out different keys & progressions for future compositions.
SHARE:
Although MSDN says you can use the FrameworkElement.Tag Property to store an arbitary object, if you try to store anything other than a string you get a System.Windows.Markup.XamlParseException. It seems I'm not the only one to notice this.
SHARE:
I've started by creating a Silverlight user control to represent a 3 octave (piano) keyboard:

This user control will use data binding (hopefully!) to highlight piano keys if they exists in user control's data context (which probably be a list of notes).
SHARE: