Skip to main content

Posts

Showing posts from 2013

Automatic Numbering for the Primary Key Column

Many of you might have come across an issue of Auto incrementing while working with database products. Truly speaking, recently I also came across one silly problem and thought of sharing it here. Imagine that at some point of time, you might want to send your new data to a back-end database. If your application supplies the auto-increment values, then what will the database do? what if application receives duplicate values from different client applications? The answer is that these auto-increment values are never sent to the database because the auto-increment column in the database table will provide a value whenever a new row is added. After each new row is added, the back-end database table generates a new-increment number and then your application will query the database to get the newly created number. Your application will then update its primary key number to the values that came from the database. This means that all the foreign key references will need t

Formatting strings in binding

Recently I get a chance for a code walk through of an WPF application in order to achieve better performance. So, during my review process, I came across this below code snippet:   <WrapPanel>         <TextBlock Text="{Binding Path=FirstName,Mode=OneWay}"/>         <TextBlock Text=" "/>         <TextBlock Text="{Binding Path=LastName,Mode=OneWay}"/>     </WrapPanel> If you will closely analyze this given snippet, you will definitely get a way to optimize it. Well, I am talking  about formatting the string as well as binding part. As most of you are aware that we have a property named StringFormat since .Net 3.5 SP1. So, why can't we use this StringFormat for our binding too. If you want to change the above code to incorporate StringFormat , then it will something look like: <WrapPanel>         <TextBlock>                 <TextBlock.Text>                     <MultiBinding String

Resizing TextBlock with resizing of window

When dealing with XAML, many of you might have came across resizing issues in which your control is getting resize but the text/image inside the control is not getting resize as per the window size(it can be other user control). So, to deal with this Microsoft provide us with a Viewbox control, in which user can set the resizing aspects as per the need and requirement. So, this article focuses mainly on the properties provided by Viewbox control with proper sample code and output. MORE...

Safest way to use RaisePropertyChanged method - MVVM series 3 of n

Background In my previous post on  Simplest MVVM Ever , I gave the simplest overview of implementing MVVM. Now moving forward, I thought to extend my previous post by picking individual areas. And this time, I selected  RaisePropertyChanged . All the developers working on XAML related apps are very well aware about the use of this RaisePropertyChanged. I am sure, most of us are also aware on where to use this. But does everyone aware about what is the proper way or let's say generic way to use it ??? Well, even if you are not aware, no problem. At the end of this post, you will surely take home a useful tip on using  RaisePropertyChanged . Introduction As we know that MVVM provides a loose coupling methodology. At lot many places it is very useful to get benefit of such architecture, but at the cost of your alertness. Because when we are talking about MVVM, we usually says that ViewModel has no knowledge about View and properties are the way, who binds View and ViewModel to

Simplest MVVM Ever - MVVM series 2 of n

Continuation to my previous article on  WHY and WHEN of MVVM , this time, I am going to tell something on how we can create a simple MVVM application with minimal complexities. I am writing this article for those, who just want to see quickly how MVVM works. It doesn't do anything fancy and uses some basic databindings and commanding stuff. This article will be helpful for all those who are looking for a quick example of how to hook the View to the ViewModel and how commands plays a role.  Today if you will surf internet, you will came across 1000s of articles discussing on what is MVVM and what are the major building blocks of it. So, I am going to repeat the same crazy thing again. But definitely, I'll brief you about major building blocks in layman, in order to make it easier to understand for beginners. Excited, eh ???  Layman introduction of building blocks    So, let's quickly start with three main layers of MVVM. Model  - Model contains the classes which ar

Why and When of MVVM - MVVM series 1 of n

Developing software is HARD. In fact, I would say, it's very HARD. Patterns and Architectural Structures help, but... it’s still hard. Like any other architectural structures, MVVM is also a structure with a set of guidelines and NOT a set of rules. In the past few months, I came across various forums and online discussions, where people often ask "Why should I use MVVM? It seems like it complicates things" and I realized that MVVM is very difficult to learn for beginners who have very little knowledge of design patterns and frameworks. As of today, if you will search MVVM in any of the search engines, you will get lot many articles written by the extremely knowledgeable through to the novices, and it is really hard to sort the wheat from the chaff. Apart from this, there are lot of resources which mention few points and miss out others, which may be very conflicting for those beginners as well as for some experienced programmers. I'm not going to call t

Microsoft Tech Days November 6 - 8

Tech.Days Online – November 6-8: All the sessions and an interview with Steve Ballmer. Have you registered?   http://lnkd.in/bdera7q This three-day virtual event will be packed with technology updates by expert presenters from Microsoft (UK and Corporate), the Microsoft MVP Community, customers and special guests.

Best Practices for ORM

Although everyone puts their complete effort to develop the best software, sometimes bad things happen. But to be on safer side we can take some precautionary measures. Well, today I want to share some of the best practices which needs to be followed while dealing with any ORMs (Object Relational Models). Most of these are common among many of the relational databases. Exception handling: One should handle only those exceptions which need to be handled, and let all others pass through. For example, if you want to handle a connection issue you should do this by catching the specific exceptions, but don't use a catch all on Exceptions with the clause "just in case" because it may lead to high performance issues. USING: As many of us know, that USING automatically handles dispose functionality. But this statement doesn’t work all the time, especially in the case of database connections. If you want to try it out, then run some overnight processes using windows services.

New Features in Vistual Studio 2013 Release Candidate

It has been great movement, great work done by VS team for making easy to use Visual Studio. There has been lot of new features in Visual Studio 2013 preview, which has some very cool features in XAML, intellisence, goto definition and many more. But in RC, most of these features are extended. Today I'll try to cover as much as possible about all these new features. So, let's start by taking them one-by-one. 1)  Intellisence in XAML - Earlier versions of VS were pretty cool but I hope, whoever working in WPF would have surely miss intellisence feature. But in RC, that is no more a limitation. So, if we let editor know where the data is, it will help us out like a friend and will make our work easier. VS2013 rc supports intellisence for DataBinding and Resources . Let's have a look of this feature in below screen shot: I ntellisence for DataBinding    I ntellisence for Resources 2) Go To Definition in XAML - This new feature in available in VS2013 RC