Thursday, August 22, 2013

WPF - The dependency property is already registered


This is the error you will face when you are copy pasting the code to write dependency property. JJoking…That is not the reason of this error. But I have received it when I copy pasted dependency property code from one of the site.
You will land up in this error when you have dependency property written in following way –
public readonly DependencyProperty SelectedItems2 =
            DependencyProperty.Register("SelectedItems2", typeof(string), typeof(ListBox), new PropertyMetadata(null));

What is missing here? - STATIC keyword.
The problem lies in a way you register your dependency property. You should not register in the default constructor of the class, but in static constructor or initialize it at the time of declaration and preceding with Static keyword. Best way to write dependency property without error is code snippet. Type ‘propdp’ then press tab twice. And then customize the property as per your requirement. This is how you can avoid this error; avoid learning of dependency property syntax and save time.
public static readonly DependencyProperty SelectedItems2 =
            DependencyProperty.Register("SelectedItems2", typeof(string), typeof(ListBox), new PropertyMetadata(null));

Hope this helps.
Cheers…
Happy Properting!!!

Wednesday, August 21, 2013

Facebook Tips & Facebook Help – How to get back up of your facebook data



Benefits of Facebook can be the topic of debate, because facebook is mainly being used for gaming, chatting and time passing. So facebook is for time pass and that can be proved without any survey and this is period. However if you have a look at facebook timeline; one can easily get the information of things you had done since you have joined facebook, places you had visited, how had you reacted to certain incidents, new friends and many incidents can be viewed from timeline. This information can be valuable to live the moments you spent. What If you facebook account gets deleted? Or you clicked on some virus based link and your facebook wall has some weird posts and now you only have option to delete the current account and get new? In such scenarios if you have the back up of facebook data then life will be easyJ.
Login to the facebook. Click on Settings icon present in right hand upper corner of your browser. The icon is of “Gear” sign. You will see numerous options on click on Gear sing. Out of these options choose “Account Settings”. You will see the screen as shown below –
 
As shown above choose the option “Download a copy of your facebook data”. Further you will be presented an option to selected for starting archive of your data on facebook as shown below –

Tuesday, August 20, 2013

Value produced by BindingExpression is not valid for target property – WPF-MVVM-Prism and Telerik control



Ahhh, Telerik - what a pain this is…Telerik controls have made my life bit hard…
I am using MaskedTextInput control and trying to Clear the text in it on the click on Clear button which is inbuilt in this control. It clears the text however does not clear the value in property bind to it in XAML. To understand what I mean here refer to following tag –
<ams:AmsMaskedTextInput Value="{Binding TemperatureValue,Mode=TwoWay, NotifyOnSourceUpdated=True,ValidatesOnDataErrors=True}" Mask="###.#" Placeholder=" " Width="150" HorizontalAlignment="Left" /> 

Here if I click on the default clear button available in masked text input, it clears the entered text however value entered by user persisted in TemperatureValue  property. So my aim to make the binding property set to null on click of default clear button available in masked input text control.
I was using the MVVM-Prism framework an hence I defined my command in view model as –
Microsoft.Practices.Prism.Commands.DelegateCommand TemperatureClearCommand { get; private set; } 
 
In initialize view model – TemperatureClearCommand = new Microsoft.Practices.Prism.Commands.DelegateCommand (OnMaskedTextInputClear);
And in callback method –
public void OnMaskedTextInputClear()
        {
                TemperatureValue = null;
                NotifyPropertyChanged(() => TemperatureValue);
        } 

Updated the XAML as follows –

Sunday, August 11, 2013

Google Tips - Create Nominee for Google Account using Inactive Account Manager




Today, Email account is inseparable part of everyone’s life. Email account is major tool of communication for all of your business and office work and up to some extent personal work. So down the line your email account becomes a repository of very important information containing important posts, links, photos and other personal data. It may be possible that for a period of time for example say few months, you could not access your email account due to your busy schedule or you are out for some work where internet connectivity is not available. In such cases it may happen that your email account may get closed. Sorry to write this but situation where in you may encounter an accident or sick or passed away. What will happen to your important personal information? It becomes very much necessary that this personal valuable information should fall in safe hands. 

Recently an incident happened with my friend. He is renowned social worker in India. He went to some remote place for the work and stayed for more than 6 months. After returning back, he found that his email account is closed and all data vanished. Hence letting the email account information to be handed over to known person during your absence is of vital importance.

To let the information fall in hands of the person who is known to you and to send you the notification well before the closure of your email account, Google has provided “Inactive Account Manager”. In short you create a nominee for your bank account; exactly in same way you create a nominee for your Google account.