About Me

reno, NV, United States
As of 2011, I have ten years experience in various technologies as C#, WPF, Java, J2EE, C++. For the past three years, I have been extensively working on various .net and java technologies including but not limited to WPF , C# , WCF and composite application guidance (Prism ).

Monday, November 15, 2010

Cannot convert the value in attribute 'Property' to object of type 'System.Windows.DependencyProperty'. isloaded


This problem is typically encountered when you are trying to use IsLoaded like a dependency property


Its wierd at the first look why IsVisible a dependency property and not IsLoaded.

Monday, May 11, 2009

Resharper 4.5 is kicka$$ :)

There is a newer release of Resharper, version 4.5 available. If you haven’t put your hands on it, I suggest you do. I could see a lot of improvements compared to the previous versions (especially performance). All licenses purchased after Dec 21, 2007 qualify for a free upgrade to ver. 4.5. According to their website these are some of the new developments.

§ Performance and memory consumption: When working on large solutions, you’ll feel a great deal of difference between ReSharper 4.0 and 4.5.

§ New solution-wide warnings and suggestions: Analyze usage of non-private types and type members within your whole solution.

§ Visual Basic 9 support: ReSharper’s cross-language refactorings and editing experience enhancements now provide support for VB9 code.

§ Extended setup for naming conventions, which are now supported by all ReSharper features.

§ New Inline Field refactoring and enhancements in existing refactorings.

§ Go to Implementation: Go from usage of a class or method straight to its end implementation, bypassing abstract classes and/or interfaces.

If you would like to see a quick demo of all the features, here they are... If you like it and would like to download the new 4.5 release follow this linky. Here is the 4.5 feature map.

If you are updating your Resharper.. Please copy your user name and license key on a notepad as a backup.
Happy Coding,


Thursday, April 23, 2009

VS 2008 Templates for Composite Application Guidance (Prism v2)

Most of the credit for this post goes truly to Knom who created the initial versions of Visual studio templates. I have been using them for a while, though I always felt that it is broken or incomplete, so here is the newer version.


The revisions in this modification are
a) The new version works only with February 2009 Composite Application Guidance. It refers to the IModuleCatalog introduced in this release.
b)The references like Microsoft.Practices.composite broken in the previous release are fixed now!
c) The new dlls like Microsoft.Practices.composite.presentation.dll are referred instead of Microsoft.Practices.composite.wpf.dll
d) Namespaces in view and presentation models are fixed in this release.
e) every module can have its own name and the same with ModuleController.
f) Unnecessary imports have been removed.
g) Slicker interface.

If you like this, please goto knom's page and contribute. I dont need any! (may be a comment if it is useful to you !) You can completely write a Prism application in less than ten minutes using this application.


a) If you have not installed Composite Application Guidance, install it here.

b) Download the Visual studio templates for composite application Binaries here.

c) Unzip this and you will find three files.
* install.bat does all the work to setup the templates (run the .VSI and add the .DLL to the global assembly cache)
* CompositeTemplateWizards.dll contains the Wizards used from the project templates. This assembly must be installed into the GAC.
* Templates.vsi is VSI installer package with all the templates (need the wizard assembly in the GAC).

d) Run the install.bat

If you are upgrading from knoms templates then just follow the same instructions and when installing, it would ask you for a over ride. Do override the old files!

Trouble shooting Notes
a) If you have more than two versions of Visual studio you might not be able to see these templates when you click "new project". In that case

Goto Programs> Microsoft VS 2008> Visual studio tools \ Visual studio 2008 command prompt

In here change your directory to the base directory where you have the install, run the following command.

gacutil.exe -i CompositeTemplateWizards.dll

Restart vs 2008 and things should start working

b) After installing the "composite application guidance 2.0" Visual studio 2008 templates, as a one time activity create a libraries folder with following libraries.

This folder will be useful in creating the Prism apps.

Tuesday, April 14, 2009

Running animations in MVVM

We implement Composite application guidance (Prism v2) in our application. Recently we wanted to run animations when something changes in ViewModel. The Viewmodel changes should initiate storyboards or run functions on view.xaml code behind.

I implemented a class ViewModelChangeDispatcher which can be useful to run animations.
You can instantiate this lightweight class from xaml as

OnSourceChangedStartStoryboard="XXXStoryBoard" />

The above VMCD is bound to Source xxxAnimation, this when changed will automatically call the storyboard...

If you want to manage multiple animations using the same, u can handle that by this code

When source is changed the event handler RunAnimation is called.

Anyway here is how I implemented ViewModelChangeDispatcher.

public class ViewModelChangeDispatcher : FrameworkElement
#region Data

public static readonly DependencyProperty SourceProperty;
public static readonly DependencyProperty OnSourceChangedStartStoryboardProperty;

// The routed event
public static RoutedEvent SourceChangedEvent;

#endregion // Data

#region Static Constructor and static methods

static ViewModelChangeDispatcher()
SourceProperty = DependencyProperty.Register(
new FrameworkPropertyMetadata(string.Empty,OnSourcePropertyChanged));

OnSourceChangedStartStoryboardProperty = DependencyProperty.Register(

//Registering the events
SourceChangedEvent = EventManager.RegisterRoutedEvent("SourceChanged",


private static void OnSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

ViewModelChangeDispatcher vmcd = d as ViewModelChangeDispatcher;
if (vmcd == null) return;

vmcd.RaiseEvent(new RoutedEventArgs(SourceChangedEvent, vmcd));
if (vmcd.OnSourceChangedStartStoryboard == null) return;


#region constructor and members
public ViewModelChangeDispatcher()
this.Visibility = Visibility.Collapsed;
this.Width = 0;
this.Height = 0;


* Source is always string.
* It is the onus of the markupextension to convert it to a string.
* */
public String Source
get { return (String)GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); }

public event RoutedEventHandler SourceChanged
add { AddHandler(SourceChangedEvent, value); }
remove { RemoveHandler(SourceChangedEvent, value); }

public Storyboard OnSourceChangedStartStoryboard
get { return (Storyboard)GetValue(OnSourceChangedStartStoryboardProperty); }
set { SetValue(OnSourceChangedStartStoryboardProperty, value); }


Please let me know if you have any comments/inputs!

Happy coding!
Pradeep Mahdevu


Also refer Josh Twist's point of view on this.
joy of code
and pavan's post here...

Pixel in genie

Composite application Guidance Prism Logging

Coming from a Java web development world, I always love the ease of use of apache commons logging, I recently implemented logging in our WPF application based on Composite Application guidance (CAL or Prism v2). We use the Microsoft way of logging, Enterprise Library 4.1. Though the performance is sluggish compared to log4net, we wanted to use this for various other reasons.

This blog entry would help you set up you CAL with enterprise logging. I created a class called CustomLogger. CustomLogger encapsulates Logger. You can either resolve ICustumLogger or ILoggerFacade to use this. ICustomLogger provides interface common to Apache commons logging and ILoggerFacade provides interface common to Enterprise Logging.

First looking at registering the ILoggerFacade. The BootStrapper overrides LoggerFacade to return the customLogger.

internal class Bootstrapper : UnityBootstrapper
// CustomLogger is a custom logger implementation.
CustomLogger logger= new CustomLogger();

protected override ILoggerFacade LoggerFacade
return logger;

protected override void ConfigureContainer()
Container.RegisterType(new ContainerControlledLifetimeManager());



We register two things with the container, the ILoggerFacade and the ICustomLogger. Though there is a mere small additional cost,the benefit of this is huge, ILoggerFacade is used by the CAL to log things in trace.log and ICutomLogger is used by app to log things.

An example of logging using this interface is ...

public XXXXXXXXXPresentationModel(IUnityContainer container,
IMagCardInfoView view,
IEventAggregator eventAggregator,
ICustomLogger logger,
IMagCardCommandsView commandsView,
IRegionManager regionManager)
: base(eventAggregator)
logger.Debug("New XXXXXX Presentation model requested.");


The ICustomLogger interface looks like

public interface ICustomLogger

void Info(string message);

void Debug(string message);

void Warn(string message);

void Exception(string message);


The CustomLogger looks like

public class CustomLogger: ICustomLogger, ILoggerFacade

public void Info(string message)
Logger.Write(message, Category.Info.ToString(), (int)Priority.High);

public void Debug(string message)
Logger.Write(message, Category.Debug.ToString(), (int)Priority.High);

public void Warn(string message)
Logger.Write(message, Category.Warn.ToString(), (int)Priority.High);

public void Exception(string message)
Logger.Write(message, Category.Exception.ToString(), (int)Priority.High);

#region ILoggerFacade Members

public void Log(string message, Category category, Priority priority)
Logger.Write(message, category.ToString(), (int)priority);


Monday, April 13, 2009

WPF UI Waiting for server animated with dependency control.

Writing a WPF application often requires communicating with Server. When the WPF application requires to contact with server, we would like to show a neat animation on the UI like Internet explorer.

This listing shows a way to create an userControl which can be used in applications like

xmlns:WA="clr-namespace:WaitingAnimated" .... />

Margin="200, 50, 300, 300"/>

In the source code attached I have a toggle button which starts/stops the animation by setting the value of IsAnimated to true or false...

private void Button_Click(object sender, RoutedEventArgs e)

animatedIcon.IsAnimated = !animatedIcon.IsAnimated;

Going thru XAML in the user control which is not rocket science but still...

The Grid.Resources has a storyboard, the repeat behavior of animation is forever and the storyboard target property is Angle of the path.

Storyboard.Target="{Binding ElementName=path}"

Path is the union of two circles. The important things in path are the rendertransform origin which translates the origin to the corresponding value, i typically define rendertransform and add all children even if i dont use to keep code extensible. Path fill is the color in the circular path which is filled .

RenderTransformOrigin="0.5,0.5" x:Name="path">

Source code here.


Blogger Syntax Highliter