Archive for category Silverlight

Getting started with Silverlight – Visual Studio 2010

Actually this is ¬†my first Silverlight application development, I didn’t get any chance to work with Silverlight in a real time project, so I just wanted to try an application with Silverlight in Visual Studio 2010. It is pretty simple like windows application. ūüôā

This is my environment: Visual Studio 2010, Silverlight 4 developer edition and Windows 7.

When I tried to create an application, I have got few version conflict problems and I resolved them. You can see in my previous post if you need. Okay.. we will see the steps.

Step 1: Open the Visual Studio and click New Project

Step 2: Choose the programming language and select Silverlight node in the left pane.

Step 3:  Select the Silverlight application on the middle pane and enter the application name on the Textbox then click ok. 

Step 4: You will be getting the following screen.

Please Note: If you want to enable the WCF RIA Services to access the external data using this application then click the check box. I don’t want to do any, so I just click ok.

Step 5: Here is our solution explorer. If you want to learn about the files and other stuffs just click here and learn more.

Step 6: Just click on the Toolbox on the left side¬†vertical¬†tab (If not shown just click View –> Toolbox OR Ctrl+W, X) and drag and drop the button.

Step 7: Modify the button properties (You can either modify in the property tab on the right side (as usual we do) OR you can modify in the XAML pane).

I have given the button¬†Name=”buttonClick”, Content=”Click”,¬†Height=”50″ and¬†Width=”100″

Step 8: Like button add TextBox and a Label as well. So our design will be displaying like this.

and the XAML:

<Grid x:Name="LayoutRoot" Background="White">
 <Button Content="Click" Height="50" HorizontalAlignment="Left" Margin="152,133,0,0" Name="buttonClick" VerticalAlignment="Top" Width="100" />
 <TextBox Height="25" HorizontalAlignment="Left" Margin="85,70,0,0" Name="textBoxEnter" VerticalAlignment="Top" Width="230" />
 <TextBlock Height="25" HorizontalAlignment="Left" Margin="85,101,0,0" Name="textBlockDisplay" Text="" VerticalAlignment="Top" Width="230" />
</Grid>

Step 9: Double click on the Button to create the click event (You can do this on the right side event tab also) and then write the c# code to getting the string form TextBox and displaying on the Label.

private void buttonClick_Click(object sender, RoutedEventArgs e)
 {
 textBlockDisplay.Text = "Hello " + textBoxEnter.Text;
 buttonClick.Content = "Clicked";
 }

Step 10: That’s all guys, just click the run button (F5) to see our 1st Silverlight application. ūüôā

Happy Silverlighing..! We will see the database access later! ūüôā

Thanks R./

Advertisements

, , , , , , , ,

1 Comment

System.NullReferenceException in Silverlight application designer in Visual Studio 2010

This is my Environment:

  1. Windows 7 64 bit
  2. VisualStudio 2010 with SilverLight 4 developer runtime

Problem:¬†After¬†upgrading¬†the SilverLight 5 client, I tried to create a SilverLight Application and then I have got the following wired error message on the design tab ūüė¶

The text format of the error is:

System.NullReferenceException
Object reference not set to an instance of an object.
at Microsoft.Windows.Design.Platform.SilverlightMetadataContext.SilverlightXamlExtensionImplementations.d__8.MoveNext()
at MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption()
at MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
at MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(Boolean convertToXamlWithErrors)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem()
at Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem()
at Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState()
at MS.Internal.Host.PersistenceSubsystem.Load()
at MS.Internal.Host.Designer.Load()
at MS.Internal.Designer.VSDesigner.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()

Solution: The problem is the conflict of SilverLight versions and I have found the solution in this thread.

Step 1: Uninstall the latest SilverLight client which is SilverLight  5, the 1st one in the below control panel screen shot

Step 2: Uninstall SilverLight 4 developer, the next 1 in the above image

Step 3: Download and Install Microsoft Silverlight 4 Tools for Visual Studio 2010 (Add-on and pre-requisite files for Visual Studio 2010 to develop Silverlight 4 and RIA Services applications)

Installing..!

Installation finished successfully.

Restart the VisualStudio¬†2010, wow.. it’s working! ūüôā

Happy Silverlighting..! Thanks R./

References:

1. http://connect.microsoft.com/VisualStudio/feedback/details/718259/new-ms-update-causes-vs2010-silverlight-project-to-have-error-in-design-wpf-editor

2. http://social.msdn.microsoft.com/Forums/en/vswpfdesigner/thread/01ce533e-ed94-48d2-8184-e2e34e6bdc6f

, , , , ,

12 Comments