when to use/uses of DependencyProperty

The main reason to create DependencyProperty is when you write you own WPF control.

The main difference is, that the value of a normal .NET property is read directly from a private member in your class, whereas the value of a DependencyProperty is resolved dynamically when calling the GetValue() method that is inherited from DependencyObject. Continue reading

Number To Bool Converter

Here is a simple IValueConverter implementation, to convert an int value (1 or 0) to corresponding bool values (true or false).

Useful if you want to bind a check box or something to a property of numeric type. Continue reading

By Sriramjithendra Posted in WPF

Passing Command Parameter for Buttons within an ItemTemplate using MVVM Pattern in WPF


In this tip, we will talk about how to pass a CommandParameter for a Button control which is used within theItemTemplate of the ListBox control. We are trying to load the list of Buttons inside the ListBox. The list of Buttons is in English and Danish language. This tip will help you to identify which Button has been pressed and how to pass the CommandParameter within the Button control in MVVM. Continue reading

By Sriramjithendra Posted in WPF

Converter to hide items when something is null or empty string

Often times in Xaml you’ve got some labels, or buttons that you don’t want to show if something in the ViewModel is null or empty. Take the example below. The ViewModel has a nullable property rating. If it is non-null a handful of controls are rendered to show it graphically and numerically. If it is null however we don’t want to see any of that stuff. This converter helps hide elements of something in the ViewModel is null or empty string.  Continue reading