Writing an auditing behavior for WPF

by Geert 13. October 2010 00:39

Recently, I needed to show the history of a field for several user controls. This includes checkboxes, textboxes, comboboxes, date/time pickers, etc. Now, how should one accomplish this?

After some searching on the internet, I found out that behaviors were the way to go. However, I have never ever done anything with behaviors in the past. Just to let you know: I just learned about behaviors 3 hours ago or something like that. So, let’s see how it worked out...

I read some short articles about behavior, for example, this one and this one.

Nice, I can do that as well (at least, I should be able to)! So, I started importing the assembly “System.Windows.Interactivity”. Too bad, it was not on my system. It turned out to be part of the Expression Blend SDK, so I quickly downloaded it and got my very own copy of the assembly.

I quickly wrote my own behavior (which is actually very simple, you can see it in the attached demo application), and then the only thing I had to do is to attach the behavior to the controls. This is the result (of the demo app):

AuditingBehavior

The rest of the time until now (appr. 1,5 hour), I used to write a demo app and this article. It’s a bit short, but I am in quite a hurry for a project which has a deadline, sorry for that.

And remember, these kinds of things are the power of WPF. Imagine doing this in another language...

AuditingBehavior.zip (797.38 kb) [Downloads: 373]

 

kick it on DotNetKicks.com

Example behavior in the form of an auditing trail (history) of controls.

Tags:

C# | WPF

Comments (1) -

Codehunts
Codehunts United States
10/15/2010 9:18:53 AM #

Nice work.To improve visitors to your site,you can submit your links in http://codehunts.com

Pingbacks and trackbacks (2)+

Comments are closed

About the Author

Geert van Horrik is an independent freelance software developer since January 1st, 2007. Since then he was been working on several projects from C++ to C# (WPF, Silverlight, ASP.NET, etc). Currently he loves to write his software using WPF (or Silverlight if WPF isn't an option).

Lately, Geert is spending a lot of time on Catel, a free open-source MVVM Framework for WPF and Silverlight. Actually, it's more than "just" an MVVM Framework, it's a complete application library!