While working in Windows you have seen that, while focusing on any TextBox the entire text inside it has been selected. This is a default behaviour of Windows, but in WPF this behaviour is not present. For this you have to write code.

If you want to add the same behaviour in your WPF application then you have to register the TextBox.GotFocus event for each textbox inside your Window and in that event implementation you have to write the code to select all the text inside the focused TextBox, right? If you do like this, then you have to write so many event registration for each one of the TextBox.

 

 

Lets say, you have a single Window with 100 TextBoxs in it. In this case though you can write the event definition inside a single implementation but you have to register the event for 100 times. Now imagine the same behaviour for 10 Windows inside the same application. Here you have to write the event implementation for each and every Window & register the event for each TextBox. This will definately clutter your code.

So, how can you get the said behaviour in your WPF application? It is a simple trick inside your App.xaml.cs file. This will be a global event handler for any TextBox in your application. If you open your App.xaml.cs you will find a overridable method named "OnStartUp". Inside this register the TextBox.GotFocus event for every TextBox before calling the OnStartup method for the base class. After doing this trick, your OnStartup method will look like this:

 

 

protected override void OnStartup(StartupEventArgs e)
{
    EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotFocusEvent, new RoutedEventHandler(TextBox_GotFocus));
    base.OnStartup(e);
}

Here, the EventManager class will be responsible to register the event handler for all TextBox. So simple right? Now add the event handler implementation for the TextBox in the same class. This will look like this:
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
{
    TextBox tb = sender as TextBox;
    tb.Focus();
    tb.SelectAll();
}  
             
Now run your application with multiple Windows having multiple TextBox on them. Focus on any TextBox having some texts inside it. You will see the same behaviour has been added to all of your TextBox.
Published by on under Tips | WPF
MoXAML is an AddIn for Visual Studio to make your coding more productive for WPF and Silverlight Applications. By using this great power toy, you can code without giving more efforts. It has lots of features like beautifying the XAML code, Keyword Lookup, better comment support for XAML, automated Dependency Property creation and more.

You can also explore the features of XAML Power Toys. This will give you a extended power to design your XAML. This is really a good AddIn not only for the designers but also for the developers. You can create your ViewModel class, create ListView or Form for selected class, extract properties to style, option to generate x:Name for controls, grouping controls inside GroupBox and lots of other goodies. Check out the site for the latest features.

Mole is a tool that integrates with Visual Studio which lets you inspect the Visual Tree of your application, view and edit properties or data, view the XAML for selected elements and more. It allows unlimited drilling to objects and sub objects.

Snoop is a tool which you can use to hook to your running WPF application and browse the Visual Tree of the application. You can also inspect and edit the properties, inspect routed events and magnify sections in the UI and also debug binding errors.

Crack.Net is a runtime debugging tool for .Net desktop applications (both WPF & WinForms) just like Mole & Snoop. It allows you to go thru the managed heap of another .Net application, view all kinds of values on different objects and also manipulate them easily. You can also read the Crack.Net article.
Published by on under .Net | Silverlight
Microsoft released Silverlight 3 on 10th July 2009 as per the schedule. You can download the SDK, Visual Studio Tools & Blend from the following location:
Silverlight 3 came with the following features:
  • Out of Browser support
  • Network status check
  • Pixel Shader Effects
  • Bitmap APIs
  • Runtime themeing support
  • Enhanced control skinning
  • Support for System Colors
  • Bitmap Caching
  • Perspective 3D view
  • GPU hardware acceleration
  • Text animation
  • H.264 support
  • RAW audio/video support
  • Save File Dialogue
  • Wrap Panel, View Box, Dock Panel
  • Support for local fonts
  • Binary XML
  • Component caching & Scene caching
Published by on under .Net | Silverlight
Azure service platform is a cloud computing platform hosted in Microsoft data centers. This provides operating system & different set of development service which the developers can use to build their own web applications or enhance them directly in that platform. Without purchasing any upfront technology, developers can create their applications more quickly & easily in the cloud. They only need working knowledge in .Net Framework & Visual Studio Environment. Azure service currently supports native languages. In future it will support many more including Microsoft & Non-Microsoft languages. Once the coding is done, the developer can build & host the application in the cloud, so that end user will be able to run it over the internet.
Azure platform consists of Windows Azure, which is an Operating System to provide on demand computing, storage and management of cloud applications. In short, Windows Azure is an Operating System for the cloud computing platform designed for utility computing. It provides facilities to write, host or manage applications & store data on demand. The service layer consists of different services like: Live Service, .Net Service, SQL Service etc. which provides building blocks within the platform for the developers.
image
Published by on under Web |

Cloud computing is a dynamic style of computing in which virtualized resources are provided as a service over the internet. The users of cloud computing need not to worry about the capital expenditure and maintenance cost of hardware and software resources. They have to pay only what they are using. This can be of two types. User can either pay the provider based on the resources consumed during the time period or a time based subscription.

Published by on under Web |

Microsoft launched their new search engine named Bing (Kumo) on 28th May in Europe which went fully online on 3rd June. This search engine was designed to help people not only to quickly find anything over the internet but also to plan a trip or make a purchase decision. Using "Bing" the end user can find any information they need on their daily basis to accomplish their tasks. Bing categories results in different category, based on which the user can find relevant results more accurately.

imageimage

image image

You can find some Tips & Tricks on Bing.com at: http://www.labnol.org/internet/bing-tips/8931/

Published by on under News |

Google Wave is a project announced by Google on 28th May 2009 at the Google I/O conference is expected to release later in 2009. This will be a next generation email subsystem designed to merge email, instant messaging, social networking & wiki featuring strong spelling/grammar checking & automated translation between nearly about 40 different languages.

The term "Waves" described by Google as "equal parts conversation and document", means any authorized participant can reply anywhere in the conversation, they can edit or can add more participants during the conversation process. All the participants will be notified of changes or replies in all the waves they are actively participating & all the modifications will be seen at real time, letter by letter. Not only this, multiple participants may edit a single wave simultaneously in the same context.

imageThis ability of Google Wave will let user to create collaborative documents modified in different location with full modification history, which can be searched by an user to view/modify any changes just like wikis.

More information about this is available in Google Wave Site.

Published by on under News |

Microsoft has recently launched Visual Studio 2010 and .Net 4.0 Beta 1 with more expressive features. Some of them are mentioned below:

[New Language Support]
Visual F# is a new programming language which actually combines functional & object oriented programming to provide scalable language for .Net.

[Test Driven Development]
Visual Studio 2010 now offers greater support for test driven development where tests can be written before the actual code as an approach to the software design.

[Multi Targeting]
By using the multi targeting feature you can also create application of earlier version in new IDE of visual studio.

[Parallel Processing]
Using the new parallel extension of .Net 4.0 developers can create application which will scale efficiently as the number of cores & processors increase.

[Security]
The new framework improvements & expanded capabilities in the security model by simplifying the security policy. Now runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests.

[Performance]
.Net framework 4.0 beta 1 now provides improvement in the startup time and faster performance for multi threaded applications.

[Lazy Initialization]
By using this feature, the memory for an object is not allocated until it is needed. This improves the performance by spreading the object allocation across the lifetime of the application.

[In-Process Execution]
This enables an application to load & activate multiple version of the CLR inside the same process. Now you can run applications those are based on the .Net 2.0 & .Net 4.0 inside the same process.

[Profiler]
In the new framework you can now attach, run and detach profiling tasks at any point of time.

[Garbage Collection]
.Net Framework 4.0 now supports background garbage collection. In earlier frameworks it was a concurrent garbage collection.

[Collection & Data Structure]
- The new framework now includes BigInteger which supports all the standard numeric operation including the bit operation.
- It now supports self balancing SortedSet tree which sorts automatically after insert/delete operation.
- A new data structure named Tuple has been introduced in this framework which can hold an ordered set of heterogeneous items.

[Exception Handling]
The new CLR can now handle any exception regarding the corrupted state of the underlying operating system.

and more…

Published by on under .Net |

Recently, I was facing performance issue while working with huge data. I need to bind those data inside a panel as Custom User Control & want to change the properties multiple times in a second. When I used less no's of data it was working fine, but, when I tried with more no of data, my application starts crying. It was a real pain to the application to start while loading those records & unfortunately I didn’t get any solution to that.

After doing a lot of analysis with VirtualizingStackPanel concept that I shared in my previous post “What is Virtualizing StackPanel?” didn’t solve my problem which I was facing due to huge no of data.

Later, I found a very good post (“WPF: Adventures in Virtualization by Mike Taulty”) shared by Dr. WPF on implementing custom Virtual Panel, which actually resolved my problem.

Here you will find some very good articles on step-by-step implementation of Virtual Panel:

Those are very nice articles to implement the custom virtual panel step-by-step & after implementation of this panel, I noticed a huge performance improvement in my application. This really helped me while working with a huge records.

Now, come to the basic concept of this virtual panel. What it actually does. It loads all the records in a different thread & populate them in the UI as much as records that can be viewable in the screen. While scrolling, it actually creates new object of the elements by virtualizing the existing elements. So, only those objects will be in the memory which are available in the screen. The rest will go for a cleanup process. Hence, improving the performance more & more…. depending on the visible UI elements.

See a nice example in this location: http://blogs.msdn.com/jgoldb/attachment/8116217.ashx

Published by on under .Net | Tips