Thursday, February 02, 2012
Visual Studio 2010 offers a collection of extensions that help the developer's life.
In this list I try to share some that I hope will help you as they have helped me.
Visual Studio Achievement Extension
This extension is less useful than the whole list, but one of my favorites.
NuGet Package Manager
This is a package management system for the platform. NET that simplifies the inclusion of third-party libraries in your projects. The included libraries are automatically updated.
Productivity Power Tools
The first extension that I installed on my dev machine. 
PowerCommands for Visual Studio 2010
This extension adds many features to the IDE.
VSCommands 2010
Navigation and generation code improvements.
Code Compare
With this extension you can compare code (in file and folder) very easily.
GhostDOC
I use this extension since many years and I can’t live without it.
It creates XML documentation from comments.
If you found other interesting extensions, do not hesitate to contact me!
Thursday, November 24, 2011
Silverlight has a method called HtmlPage.PopupWindow() that opens new web browser window with a specific page.
You can find this method in the namespace System.Windows.Browser.
If you haven’t in your project, add a reference to System.Windows.Browser.
The method HtmlPage.PopupWindow() has three parameters:
- Uri – location to browse
- String – the target window
- HtmlPopupWindowOptions – a class with the window options (full list of properties http://msdn.microsoft.com/en-us/library/system.windows.browser.htmlpopupwindowoptions(v=vs.95).aspx)
For a security reason of Silverlight the call to HtmlPage.PopupWindow() is allowed through any user input like a button, hyperlink, etc.
The code is very simple:
var options = new HtmlPopupWindowOptions {Left = 0, Top = 0, Width = 800, Height = 600};
if (HtmlPage.IsPopupWindowAllowed)
HtmlPage.PopupWindow(new Uri("http://geekswithblogs.net/"), "new", options);
The property IsPopupWindowAllowed is used to check whether the window is enabled to open popup.
In this post I show how you can easily add a control to a silverlight grid layout from code behind.
First you draw the grid in the xaml.
<Grid x:Name="LayoutRoot" Background="Red">
<Grid.RowDefinitions>
<RowDefinition Height="20">
</RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300">
</ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
Now in the page constructor add the following code.
public MainPage()
{
InitializeComponent();
var myButton = new Button
{
Name = "btnOk",
Content = "Ok",
};
myButton.SetValue(Grid.RowProperty, 1);
myButton.SetValue(Grid.ColumnProperty, 1);
myButton.Click += myButton_Click;
LayoutRoot.Children.Add(myButton);
}
Also add the evento of the button.
void myButton_Click(object sender, RoutedEventArgs e)
{
}
The code needs no comment because it’s very simple.
The only important thing is the method SetValue because it is used to set XAML attribute of element.
For a better understanding I have created an example that you can download from here.
Monday, August 08, 2011
In many projects we need to show data in a complex way. For example graphs, table or more.
In the Lightswitch applications you can create custom controls in Silverlight and simply implement them.
In this article I want to show a small example of how to implement Silverlight slider control during data entry.
Create a new Lightswitch project.

Create new table.

Call the new table “ClassRoom” and insert the follow fields.

Add a new screen with the follow options.

Run the project and insert some example data.

Stop the debugging and insert a new screen with follow options.

After this, select File –> Add –> New Project, select a Silverlight Class Library type. Call it “SilverlightControlLibrary”.

Select the SilverlightControlLibrary project –> Add –> New Item and select Silverlight User Control.
Call it “SliderControl.xaml”.
In the SliderControl.xaml drag and drop the control “Slider” from Toolbox.

It appears like this.

In the xaml add this property to the slider properties.
Value="{Binding Screen.ClassRooms.SelectedItem.Age}"
Return to the “ClassRoomsListDetail” screen. Select “Rows Layout – Class Room Details”. Click Add –> New Custom Control. Appears a screen like this.

Click “Add Reference”. Click “Projects”, select “SilverlightControlLibrary” and click “Ok”.

Open the new reference and select “SliderControl”.

Press “F5” and run project. The new screen appears like this.

Now you can enjoy with Silverlight Custom Control into Lightswitch application. With this method you can create a thousand kind of controls.
As always I include a sample project.
Sunday, July 31, 2011
My last love is called Microsoft Visual Studio Lightswitch.
After the official launch (26th of July) I installed the official release instantly.
The setup is very easy but I want to share my installation tutorial because Lightswitch was created for develop application easily and quickly way.
That’s why you can install it even though you are not a programmer.
First of all, mount the iso image of installation and launch the setup.
Accept the license.

Click customize.

Check if the path of Microsoft Visual Studio installation is right.
Click next and wait the finish of installation.

Click Launch.

When Visual Studio is started, choose New Project and select Lightswitch type of project.
Select your preferred language (I hope that is C#
)

When you see the follow screenshot, you can start to enjoy with Microsoft Visual Studio Lightswitch.

Monday, July 11, 2011
IIS Express is a lightweight, self-contained version of IIS optimized for developers.
It is installed when you install Visual Studio 2010 SP1 or you can install separately using Web Platform Installer.
Convert your application for using IIS Express is very simple.
You can right clicking on the project and select "Use IIS Express"

You can also access to this feature from Project Properties. Right click on the project, select "Properties" and then switch to tab "Web". Select "Use Local IIS Web server" and check "Use IIS Express".

If you want to use IIS Express in all new project, you go to Tools -> Options -> Projects and Solutions -> Web Projects and select "Use IIS Express for new file based web sites and projects".
The new projects will use IIS Express by default.

Thursday, June 30, 2011
To protect the privacy when I surf over the internet, I use AdBlockPlus add-in for Firefox. But when I use Internet Explorer 9, this add-in don’t work.
Internet Explorer 9 (and I hope Internet Explorer 10) has built in feature to add a TPL. There is a javascript function to call named msAddTrackingProtectionList. This function has two parameter: the first one is the link of TPL and the second one is the Title of TPL.
To do this is very easy. Add this simple javascript function on your website or in a blank html page.
<a href="javascript:window.external.msAddTrackingProtectionList('http://easylist-msie.adblockplus.org/easyprivacy.tpl', 'EasyList Privacy')">EasyPrivacy TPL</a>
The effect is below:
EasyPrivacy TPL
After click appears a confirmation prompt.
For security reason this javascript function can only be called from a user interaction: buttons, links, forms.
For more information about msAddTrackingProtectionList function go to Msdn Library.
For more information about EasyList go to Easy List TPL.
Tuesday, June 14, 2011
When you develop a Windows Phone 7 application you can debug it on emulator or on the device. If you use the device you must open the Zune software to connect to the phone. But with this method you can’t access to the hub and to media library.
The workaround is very simple.
Close Zune and from command line launch the WPConnect.exe that is located in C:\Program Files\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect (64 bit operative system) or C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Tools\WPConnect. When you obtain the message “Connection established” you can debug the application on Windows Phone 7 without Zune.

Thursday, June 09, 2011
In the previous post I explained how to prevent the automatic lock screen of Windows Phone.
This feature is very good but it uses a lot of power. The workaround is to run the application under the lock screen.
Similar to UserIdleDetectionMode in the class PhoneApplicationService there is a property called ApplicationIdleDetectionMode. By default is set to Enable. When you set to Disabled the Windows Phone 7 doesn’t deactivate the application when the phone is locked and your application keep running.
Unlike with UserIdleDetectionMode when you set to Disabled it doesn’t re-enabled. Will be reset next time you restart the application.
Be careful because the Application Certification Requirements document (PDF) specifies the users must be able to configure this option from UI.
Wednesday, June 01, 2011
As everyone knows, Windows Phone 7 allows the execution of a single application developed by third parties to guarantee performance and resources needed to execute the application.
The process is terminated when the user exits by pressing the back button, the windows button and when you call task or chooser (see the relative articles), with some exceptions.
The process can also be closed after a period of inactivity (you can set this period in the Windows Phone 7 Settings).
Windows Phone 7 if it does not receive user input through touch or hardware buttons,the device locks the screen, turning it off and closing the running application.
However, there are applications that need to work even without that the user is working (web browser, document visualizer and much more) and it is therefore necessary to keep alive the screen. In this case there is a simple property to change called PhoneApplicationService.Current.UserIdleDetectionMode
As always I attach to the article an example that you can download here.
That’s all folks!!!