In this article, a discussion of a few more operating system integration features in Silverlight 5 including: Default Filename for SaveFileDialog, 64-bit browser support and Power Awareness for Media Applications. Please review the Roadmap for the series before going any further.
Included, the Roadmap for the series below as you may want to visit other sections as you learn Silverlight 5. I picked the following features as I thought that you may find them useful in your day-to-day work. If you want a specific topic covered then please leave it in the comments below.
In previous version of Silverlight, you could not specify the default filename for the SaveFileDialog message. In Silverlight 5 you can very easily.
Fire up a new Silverlight 5 project and give it any name that you want. We are going to create a simple application that contains one button and when the user clicks it the SaveFileDialog will appear with a default filename.
Switch over to the MainPage.xaml and add in the following code:
1: <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> 2: <Button x:Name="btnSaveFile" Content="Save File Dialog" Click="btnSaveFile_Click"/> 3: </StackPanel>
1: <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
2: <Button x:Name="btnSaveFile" Content="Save File Dialog" Click="btnSaveFile_Click"/>
3: </StackPanel>
Let’s switch back over to the MainPage.xaml.cs and add the following code to our button event handler:
1: private void btnSaveFile_Click(object sender, RoutedEventArgs e) 2: { 3: var saveFileDialog1 = new SaveFileDialog 4: { 5: Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif", 6: DefaultFileName = "YouCanNowHaveADefaultFileName.jpeg" 7: }; 8: saveFileDialog1.ShowDialog(); 9: }
1: private void btnSaveFile_Click(object sender, RoutedEventArgs e)
2: {
3: var saveFileDialog1 = new SaveFileDialog
4: {
5: Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif",
6: DefaultFileName = "YouCanNowHaveADefaultFileName.jpeg"
7: };
8: saveFileDialog1.ShowDialog();
9: }
If we run the application now, we will see the following prompt.
Read the full post
November is gone, per what Scott Gu said, where's Silverlight 5?