Nirav's Blog

Tuesday, April 13, 2010

Silverlight Image Button Control

Hi Guys,
If you came across certain requirements where you need to use an ImageButton control, you will notice that there is no out of box image button available in Silverlight. Actually it is very simple to use out of box Button control as Image button control. You just need to modify the control template of Button control to make it an ImageButton control.
          When you assign an ImageBrush as background of a button, you will not be able to see the image as background of the button because there lies certain xaml elements in front of the image. To achive such look you need to tweak the control template of the button a little bit.

I am providing you the style which will help you to achive the desired Image Button look for button control.

If you edit the control template of a button, you will see a Rectangle(BackgroundGradient) and a Border(BackgroundAnimation) as shown below:
Make visibility property of both of these control to 'Collapsed'.

Now, set image as background of the button.




Similarly, you can use the similar idea for ToggleButton also.
In case of ToggleButton you may need to require to switch the background image based on whether ToggleButton's property 'IsChecked' is True or False.

Here is a sample which convers both of these scenarios.

http://cid-cd9cdbf38105503c.skydrive.live.com/self.aspx/Blog%20Posts/ButtonStyleDemo.zip

Friday, March 5, 2010

Best Place to Learn Basic Concepts of WPF and Silverlight

Guys, visit http://www.wpftutorial.net/ to have in depth understanding of all the basic concepts related to WPF and Silverlight.

Thursday, February 11, 2010

Expression Blend Tutorials

Hi guys,
I found very good tutorials published by a blogger named "Gavin Wignall" on his blog. It will be very useful to you if you are a beginner. Have a look at : http://www.silverlightbuzz.com/tutorials/

Some more essential learning videos at: http://dotnet.dzone.com/articles/expression-blend-essentials

http://victorgaudioso.wordpress.com/2010/02/27/new-silverlight-video-tutorial-the-blend-ide-%E2%80%93-part-4-the-objects-timeline-and-states-panel/

Tuesday, February 9, 2010

Silverlight Textblock Styling

As you know that Silverlight textblock does not have any styling provision, you cannot have background or border set for Textblock. To come over this limitation, I have used a TextBox with its properties IsReadOnly set to True and IsEnabled set to False. I am providing a style which you can apply directly to a textbox. Only thing you need to do is that use textbox instead of textblock where you required some stylized textblock.

You can user the xaml file which contains style and Textbox indicating how to use the same.
Here is the url:

http://cid-cd9cdbf38105503c.skydrive.live.com/self.aspx/Blog%20Posts/ReadOnlyTextBlock%20Style.txt

Friday, December 18, 2009

WPF Multi Threading : Display loader using a separate thread while downloading data from remote server

I came across a problem while developing an application.
On click of a button I need to download some data from a remote server using web service. Once I start downloading data, I was required to show loader animation on the screen. Because the data I was downloading were huge, the application was getting stuck. With this situation the loader animation was not getting displayed on the screen. In such scenario, user has no clue about what happened with the application. The reason for this was the huge data being downloaded from the application and all these was performed in single thread.
I want loader animation to keep displaying in such scenarios। To achieve this I created a new thread which downloads data from the remote server. So even if there is some additional pain to one thread, it does not make other thread down. So with loader animation and data download happened in separate threads, both the operations remains intact. With this approach I can display loader animation without getting affected by the other thread which is downloading data from remote server.


Download Sample Code from here: http://cid-cd9cdbf38105503c.skydrive.live.com/self.aspx/Blog%20Posts/WpfMultiThread.zip

Microsoft Silverlight 4 Beta

With the release of Silverlight 4 beta, Microsoft has provided some excellent features which make silverlight more suitable for business applications.
Tim Heuer has a very good post on his blog about all these features.
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx
As per my opinion the most impressive features are: enhanced capabilities of Out-Of-Browser applications which can access local machine assets and Multi-touch capabilities.
With Silverlight 4 Beta you can develop an application which can access local file system, access web cam and printer, run Office applications etc. More tooling support is available as well with Visual Studio 2010 Beta.
There are many more enhancements provided with Silverlight 4 Beta. You can get detailed information about all of them at http://silverlight.net/getstarted/silverlight-4-beta/