Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

.Net

Showing posts with label .Net. Show all posts

Sometimes we write the following code while working with EventHandler and that may create some problems. I will discuss this later on. Let us see the code:


                private void RaiseOperationComplete(EventArgs e)
                {
                    if(OperationComplete != null)
                    {
                        OperationComplete(this, e);
                    }
                }



In the above case, suppose two thread subscribed to the same OperationComplete handler and one unsubscribed the event. In such scenario the OperationComplete event will become null and for the next thread due to the event is null it will not execute. This happens mainly in multithreaded applications but you can't guarantee for single threaded application too.

So what to do? How can we make sure that our application will not come into such situation and work properly?

Published by on under .Net | Silverlight

Silverlight 4 has the capability of accessing the COM object using the COM API. You can access any program installed in your PC using those APIs in Silverlight. You can open Notepad, Word, Excel or Outlook from Silverlight application.

 

Here I will demonstrate you the step-by-step tutorial on opening an Microsoft Excel book followed by data sharing between the Silverlight application and the Excel Sheet. Here we will use a DataGrid which will load some customer information. Then we will pass the data to the Excel Sheet and then we will modify the data in the external application (i.e. inside the Excel sheet). You will see that, the modified data will reflect automatically to the Silverlight Application.

Published by on under .Net | C# 4.0
In this article, I am going to discuss with you regarding the Drag and Drop functionality inside a Silverlight ListBox control. This article will also cover the Drag and Drop operation between two ListBox control. We will use here the Silvelright 4 Toolkit to implement the feature.


Drag & Drop functionality is not present in Silverlight ListBox by default. Hence, there was a big problem implementing the feature. We had to write a huge code for this feature. But using Silvelright Toolkit you can do it very easily. You can download the Silverlight 4 Toolkit from the CodePlex Silverlight Toolkit site.

Published by on under .Net | Silverlight
Silverlight BusyIndicator is not a new thing in Silverlight. It was first added in Silverlight 3 Toolkit in November 2009 release (if I am not wrong). In this post I will describe about this for those who wants to know about it.

So, What is this Busy Indicator? Busy indicator is a tool which you can add in your Silverlight application to show a loading indication to your user while saving some sort of operation in database. Generally it is useful when you calling your WCF Service to store something in server or retrieving some data from server.

Published by on under .Net | Silverlight
You all know that Visual Studio 2010 is now available in its RTM version. There are lots of features available in Visual Studio 2010. In this tip, I will talk about the incremental search functionality available inside it, which is very useful in day to day life of coding.

So, what is the incremental search? Incremental search is a mechanism in Visual Studio 2010 by which you can search and focus on the searched keyword without any UI blocking from the user end. You don’t have to open the find dialog while searching for a specific keyword in your editor window. Interested to know how it works?

Published by on under .Net | Tips
In my last chapter i.e. "Silverlight Tutorials Chapter 2: Introduction to Silverlight Application Development" we discussed on how to create a new Silverlight project, the structure of the project solution and later in this chapter we discussed on UserControls and various ways of development. After reading that chapter you are now comfortable to create Silverlight application and UserControls for your application.

Today I am publishing the 3rd Chapter i.e. "Introduction To Panels". In this Chapter I will describe about different Panels available in Silverlight. After reading this chapter you will be familiar with various types of Silverlight Panels. As this tutorial is mainly targeted for Silverlight 4, hence you will find some panels unavailable in the earlier versions of Silverlight.


Published by on under .Net | Silverlight
Silverlight 4 now came up with the support of Command Binding. Using Command binding you can easily develop your Silverlight MVVM (Model-View-ViewModel) applications where your view will not know about data. In this article, I will describe you the Command binding feature in Silverlight 4 Step-by-Step.

In this example, I will create a Customer View which will load the customer information from the code behind once we click the button “Load Customers”. The button will have a command associated with it to load the records instead of loading on click event. This ensures that the view will have less code & no relation with the data.

Published by on under .Net | Silverlight
Hope, you read my first chapter of the Silverlight Tutorial “Silverlight Tutorials Chapter 1: Introduction to Silverlight”. In that post, we learned about the very basic informations on Silverlight, it’s System Requirements, pre-requisite to create a Silverlight application, XAP file, XAML file and hosting a Silverlight application.

In this chapter we will first discuss on how to create a new Silverlight project and the structure of it. Later in this chapter we will discuss on UserControls and various ways of development. After reading this chapter you will be able to create a HelloSilverlight application and UserControls for your application.

Published by on under .Net | Silverlight
Couple of days ago, I started working on writing Silverlight Tutorial for Beginners on request of Mr. Sheo Narayan (Web Master) from DotNetFunda.com. I was busy for last few days to publish it online. I was really excited for it. Today, I am announcing my first Chapter of the Silverlight Tutorial for the public view. It will be a continuous process to complete the full tutorial. Please keep an eye for the next publication.

Please don't forget to provide your comments or suggestions.

In this chapter of the tutorial, you will learn about the very basic information on Silverlight i.e. what is Silverlight, what is the System Requirements for installing Silverlight and the pre-requisite to create a Silverlight application. After reading this chapter you will come to know about XAML, XAP file, Application XAML and how to host a Silverlight application.
Published by on under .Net | Silverlight
Silverlight 4 now has support for installing out-of-browser application silently. If you are new to Silverlight Out-of-Browser application development, you can read the complete guide in “How can you implement the Silverlight 3 Out Of Browser feature?” Also have a look into the following article to get the basic understanding of Silverlight 4 Out Of Browser feature “Silverlight 4: How can I create customized OOB Window?

Hope, you read my previous articles on the Out of Browser application development and have confident building application. In those articles you have seen that I wrote code for installing the OOB application from browser window. Now imagine some scenarios where you want to install the Silverlight application (XAP) using your Installer silently without the user interaction. How can you do that? Silverlight 4 now came up with that feature for you. In this article I will describe it and after reading it you will be able to install your Silverlight OOB Application (XAP) silently in your local drive and can run it from the desktop or startmenu without opening the browser.

Published by on under .Net | Silverlight

Silverlight 4 Printing API Demo Silverlight 4 now supports printing functionality using the Printing APIs. Using the APIs, you can now print your whole application screen or a portion of the application. Also, you can customize the look while you printing your part/full application.

 

In this post, I will step you guys to the depth of the printing API. Don’t forget to share your thoughts. Suggestions are always welcome. This will help me to improve my articles.

 

Published by on under .Net | Silverlight

Microsoft has just released the Silverlight 4 RC with several changes in the Silverlight runtime & in the Silverlight tools. Though there are couple of changes since Silverlight 3 & since Silverlight 4 Beta but it supports most of the Silverlight 3 applications by using Quirks mode. In some cases your earlier application will break or behave differently.

In this post I will describe you both the breaking changes in Silverlight 4 since Silverlight 3 & Silverlight 4 Beta. But before going to the discussion on the breaking changes, let me tell you what is Quirks mode. Quirks mode is a behaviour by which your previous application will work on the new runtime. Simple example is that, if you have Silverlight 3 compiled application it will try to run in Silverlight 4 (some cases it will fail) using quirks mode but if you compile the same application in Silverlight 4 it will not use the quirks mode and through errors on the changes.

 

What’s new in Silverlight 4:

  • XAP Signing
  • Custom Chrome Window
  • WebCam/Mic Configuration Preview
  • Text position and Selection API
  • Pinned full screen mode on secondary display
  • Support for Private Browsing
  • RichTextBox XAML clipboard format
  • Elevated apps doesn’t have Sockets Security Restrictions
  • Support for querying printer page size and printable area
  • XmlnsPrefix & XmlnsDefinition attributes has been added

 

Breaking Changes since Silverlight 3:

So, lets start with describing the breaking changes in Silverlight 4 since Silverlight 3.

  • Mouse Wheel Support - Silverlight 4 controls (ListBox, TextBox, ComboBox, ScrollViewer, Calendar, DatePicker, DataGrid) now have support for Mouse Wheel.
  • Shared BitmapImage Source – Now Silverlight 4 will render the images properly if more than one Image controls are sharing the same BitmapImage source.
  • ImageBrush.ImageSource returns ImageSource – ImageBrush.ImageSource in Silverlight 4 now returns ImageSource instead of UriSource which could be WritableBitmap or BitmapImage.
  • Keyboard Navigation in TabControl – Keyboard navigation in TabControl was a feature in Silverlight 3 having an issue with the TabItem activation. Previously pressing Up Arrow activated the next TabItem and pressing Down Arrow activated the previous TabItem. In this release they fixed it to properly activate the TabItem. In Silverlight 4 if you press Up Arrow it will activate the previous TabItem & pressing Down Arrow will activate the next TabItem.
  • Automation focus in DataGridCell - DataGridCell now receives automation focus when currency changes in the DataGrid, rather than focusing on the other part of the DataGrid.
  • Hit Test while Toggling Full Screen Mode – While toggling full screen mode Silverlight 4 will now rerun hit testing. This allows controls that were under the mouse before toggling to update the MoouseEnter state if necessary.
  • Whitespace handling with Span tag – TextBlock and RichTextArea now accepts text content & creates implicit runs generating whitespaces between inlines separated by CRLF.
  • DisplayMemberPath & ItemTemplate recreates all containers – Silverlight 4 now recreates all containers by invalidating them while there is any change in DisplayMemberPath or in ItemTemplate properties of the ItemControl.
  • New XAML Parser – Silverlight 4 now includes all new XAML Parser along with the previous XAML Parser. As per the runtime version detected in the application manifest it will parse the XAML in the appropriate parser. Apart from that, it has now additional benefits like “Better XAML compatibility”, “Greater parsing correctness & consistency”, “Better feedback error mechanism”, “Performance improvement”.
  • Panels Clear() method calls InvalidateMeasure – If you call the Clear() method of the Silverlight 4 panel it will now explicitly call InvalidateMeasure.
  • Virtualizing Stack Panel now scrolls by 3 lines – Mouse Wheel scroll in Silverlight 4’s Virtualizing Stack Panel will scroll by three (3) lines instead of one (1) line.

 

Breaking Changes since Silverlight 4 Beta:

If you were exploring Silverlight 4 Beta this section will be most important for you. There are some changes in both the runtime & tool since the beta release. So before starting with that please read the same carefully.

  • Removed TextSelection.CanInsert – TextSelection.CanInsert is now no longer available in Silverlight 4.
  • RichTextArea changed to RichTextBox – RichTextArea now renamed to RichTextBox.
  • RichTextBox.TextDecorations no longer exists – RichTextBox.TextDecoration is not available now. Instead of it you can use Inline.TextDecorations.
  • Default value to RichTextBox.TextWrapping – Silverlight 4 now has a default value of RichTextBox.TextWrapping to Wrap. If you don’t want to wrap your content you have to explicitly set it to NoWrap.
  • HtmlBrush renamed to WebBrowserBrush – In Silverlight 4 HtmlBrush now renamed to WebBrowserBrush.
  • COM Interoperability – COM Interoperability types are now moved to System.Runtime.InteropServices instead of System.Windows.Interop namespace.
  • WebCam/Output Protection Support – There has been a huge changes in the webcam/output protection support:
      • CanEnableHDCP renamed to CanEnableHdcp
      • CanEnableCGMSA renamed to CanEnableCgmsa
      • VGA, DVI, HDMI, LVDS, SDI, UDIExternal, UDIInternal also renamed to similar naming convention
      • VideoFormat.Height and VideoFormat.Width renamed to VideoFormat.PixelHeight and VideoFormat.PixelWidth respectively
      • AsyncCaptureImage call now changed to CaptureImageAsync
  • NotificationWindow – NotificationWindow.Visible property has been changed to NotificationWindow.Visibility
Published by on under .Net | News

In this post I will talk for one of the new feature in C# 4.0 – Named and Optional Parameter. Actually these are not a single feature but two different feature. You can get more benefit if you work with them together. So, what are those? Named parameter is a way to provide an parameter to the method using the name of the corresponding parameter instead of its position in the parameter list. Whereas, optional parameter allows you to omit arguments to member invocation.

Published by on under .Net | C# 4.0
Microsoft just released Visual Studio 2010 Release Candidate (RC) & is now available for MSDN Subscribers. It will be available publicly by this Wednesday, 10th February 2010. If you are a MSDN Subscriber, you can download it from MSDN site: http://msdn.microsoft.com/en-in/default(en-us).aspx
Visual Studio 2010 RC has a “Go-Live” license, means you can develop softwares/applications using it & publish it. As you all know the features of Visual Studio 2010 in the Beta release, but I am again posting the link of Visual Studio RC features & walkthrough guide here so that it will be beneficial for the new users.
Go here & have a look into the Visual Studio 2010 RC features and walkthrough guide: http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx
One update regarding the RC release is it doesn’t support Silverlight 4 but you can load/create Silverlight 3 projects using that. According to Scott in his Blog Post: “Silverlight 3 projects are supported with today’s VS 2010 RC build – however Silverlight 4 projects are not yet supported.  We will be adding VS 2010 RC support for SL4 with the next public Silverlight 4 drop. If you are doing active Silverlight 4 development today we recommend staying with the VS10 Beta 2 build for now.” Hence, those who are actively working on Silverlight 4 should work on Visual Studio 2010 Beta 2 instead of upgrading to the Release Candidate.
Complete this survey for Visual Studio 2010 and .NET Framework 4 Release Candidate: https://mscuillume.smdisp.net/Collector/Survey.ashx?Name=VS2010-RC
Last but not least, if you have any issue working with the RC version of Visual Studio 2010 or if you find any bug or if you have any future suggestions please never forget to report it at Microsoft Connect site: https://connect.microsoft.com/VisualStudio
Published by on under .Net | News

In this post I will discuss on how to create a Silverlight arrow. This will be beneficial for implementing Silverlight presentation where you can add some arrows to point to some blocks. This is simple enough to implement & will be beneficial for the beginners.

Create a Silverlight project. Now add a public class “Arrow” in it. Inside the Arrow.cs you have to add three lines (one is the base line, second is the left arrow head & the third is the right arrow head). Next you have to add those three lines inside a Panel.

Let’s start with creating the simple arrow in step-by-step process. First step is to create the base line of the arrow. Create a Line and set it’s (x1, y1) & (x2, y2). This will create the line.

private static Line CreateBaseLine(double startX, double startY, double length, Brush lineBrush, double thickness)
        {
            Line arrowLine = new Line();
            arrowLine.Stroke = lineBrush;
            arrowLine.StrokeThickness = thickness;
            arrowLine.X1 = startX;
            arrowLine.X2 = length;
            arrowLine.Y1 = startY;
            arrowLine.Y2 = startY;
            return arrowLine;
        }
Now lets create the left arrow head. The approach to it is same as creating the base line. Here only you have to pass the instance of the base line for calculating the (x1, y1).
private static Line CreateLeftArrowHead(Brush lineBrush, double thickness, Line arrowLine)
        {
            Line arrowLeft = new Line();
            arrowLeft.Stroke = lineBrush;
            arrowLeft.StrokeThickness = thickness;
            arrowLeft.X1 = arrowLine.X2 - 10.00;
            arrowLeft.X2 = arrowLine.X2;
            arrowLeft.Y1 = arrowLine.Y2 - 10.00;
            arrowLeft.Y2 = arrowLine.Y2;
            return arrowLeft;
        }
Creation of right arrow head is also similar to the one I mentioned for creating the left arrow head. The difference here is the y1.
private static Line CreateRightArrowHead(Brush lineBrush, double thickness, Line arrowLine)
        {
            Line arrowRight = new Line();
            arrowRight.Stroke = lineBrush;
            arrowRight.StrokeThickness = thickness;
            arrowRight.X1 = arrowLine.X2 - 10.00;
            arrowRight.X2 = arrowLine.X2;
            arrowRight.Y1 = arrowLine.Y2 + 10.00;
            arrowRight.Y2 = arrowLine.Y2;
            return arrowRight;
        }

Here instead of creating two separate methods for creating the two arrow heads you can just create only one method & pass the calculated (x1, y1) & (x2, y2). This is the simple approach mentioned here to give an idea to the beginner to create an arrow. It can be modified to implement some complex arrows like Horizontal, Vertical or even better Connected Arrows.

Download Sample Application: Silverlight Arrow Demo

Published by on under .Net | Silverlight