Windows Presentation Foundation provides a simple way to validate user input on your data-bound controls, and it's completely customizable, too.  By writing a custom class deriving from ValidationRule, and adding an error template to our control, we can have consistent UI notification of invalid input according to our specific needs. 

A simple example would be a TextBox which requires a positive integer input.  First, we write our custom validation rule.

public  class posintValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
{
string _strInt = value.ToString();
int _int = -1;
if (!Int32.TryParse(_strInt, out _int))
return...

Lino Tadros, President and CEO of Falafel Software, has been invited to speak at the DevReach conference in Sofia, Bulgaria.

Lino held two very popular sessions last year on LINQ and Silverlight, and this year is doubling it up with four sessions:

  • To AJAX or not to AJAX
  • Silverlight 2.0 made easy
  • Building Telerik Trainer in WPF and LINQ
  • How to bet on the right technology

I know we would all like to know the answer to the fourth question! So be sure to attend if you can make it, there are a lot of other good speakers too, and ...

When your WPF project gets large with a well structured class diagram, you may run into a case where you need to add a dependency property to a class that it is not convenient to inherit from a dependency object. In that case you need a little help from a helper class. I recently ran into this little problem and came up with this class.

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Data; using System.Threading; using System.Windows.Threading; namespace WpfDPHelperTest { /// <summary> /// Gives you a place to host a DependencyProperty without having the owner ///...

If you've ever edited a template in Microsoft Expression Blend, you'll be able to relate to this blog. Woah - that's a lot of code!  For those of use whose first language is something other than XAML, the default styles generated in Blend are pretty intimidating. Now, I know there are gurus out there who know exactly what every one of those settings and templatebindings do, but for the rest of us, there has got to be a simpler place to start. Well, there is. It's a handy little download you can get straight from your Visual Studio help called ...

.NET 3.5 includes new abilities to easily leverage web services and Windows Communication Foundation (WCF) services from AJAX enabled web applications. For example, here is a new "ASP.NET Web Service Application" with a single GetMessage() method:

namespace WebServiceAjax { [WebService(Namespace = "http://Falafel.com/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] // To allow this Web Service to be called from script, // using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class Service1 : System.Web.Services.WebService { [WebMethod] public string GetMessage() { return "Howdy"; } } }

Notice the attribute System.Web.Script.Services.ScriptService that allows the web service to be ...

By the time I found the handy JavaScriptSerializer class, it had been introduced, deprecated and brought back from the hellish purgatory where Microsoft keeps objects that have outlived their usefulness.  JavaScriptSerializer is used internally by MS AJAX to move .NET types to JSON strings and back again. A public version of the class is available in the System.Web.Script.Serialization namespace and can be used to shuttle your own objects between .NET code on the server and JavaScript/JSON/AJAX on the client. Consider the ubiquitous Foo class:

public  class Foo
{
   private  string _bar;
   public  string Bar
  {
     get {  return _bar; }
     set...

So, let's say you've got a UserControl in a project that you would like to reference using interfaces without a direct reference to the UserControl's project. Now say you want to bind to a DependencyProperty in the UserControl. An interface to the UserControl doesn't help with the DependencyProperty. When I tackled this issue, I was unable to find any example of it anywhere on the Internet.

In the main project, we have the following XAML code to display a button for adding our UserControl to a StackPanel and a TextBox to test our Binding:

<Window x:Class="WpfBindingToExternal.Window1" xmlns...

Most of my development is web apps, so when I was working on a windows app for a customer today, I noticed that there was an extra file or two being generated with the name of the app followed by ".vshost.exe". What was it? Where did it come from? Do I need to redistribute it?

It turns out that this file is automatically generated to help the Visual Studio IDE get the job done in terms of debugging and overall user experience. There's a great post here that provides a lot of information. Another resulution from that article is that ...

Hello, my name is Shane Laurent and I’m a new employee at Falafel and truth be told new to Blogging.  My goal is to research new tools, technologies, and software methodologies and then share my findings with the readers of the blog.  So on to the topic of my entry “How to Clean Up Your Desktop Clutter”.

I don’t know about you but it seems my desktop always gets filled up with shortcuts to other applications or to websites that I want to be able to quickly access again.  I had always thought about writing an application ...

A customer recently had a problem where their app couldn't access certain rows in a database. Attempting to select these rows yielded a SQL Server error: An error occurred while executing batch. Error message is: Arithmetic Overflow. Further investigation revealed that the error was caused by attempting to select the value in a column of type float. Casting the column to a varchar yielded the value #1.INF, which some research revealed was a value representing positive infinity. Since I was tasked with the job of cleansing these infinity values from the database and also ensuring that all logic accessing these ...

I was recently working on a WPF form that allowed users to edit data stored in an XML file.  In the process, I learned a lot about simplifying my databinding code.  As a WPF newbie myself, I found the use of datacontexts on parent elements just pretty cool.  You can bind whole blocks of elements to the same source, and they are all updated together with almost no code-behind whatsoever.

For example, consider the following block of xml to be loaded into a WPF form

<files>  <localfiles  type="pictures"  description="local picture files">  <file  name...

Introduction

Why should everyone know these stored procedures? Let me explain by telling a story. Up until recently, I've done a lot of my SQL development work right inside Visual Studio. The Server Explorer did a good job of displaying the information I wanted and made it easy to create and modify tables and stored procedures. This was up until VS 2008, when the Server Explorer started to get a lot more finicky. The biggest problems seemed to happen if the database connection dropped for some reason (VPN disconnect, connection terminated by server, laptop went to sleep). In prior versions, ...

With projects, as with most other things in life, only one thing is certain, and that is change. This blog talks about how to cope with change using tools like Falafel Software's ActiveFocus.

Embracing change

Many project management tools, for instance Microsoft Project, allow you plan out your projects in great detail up front, defining tasks, allocating resources, mapping out milestones and calculating finish dates and critical paths. Then the project starts and reality sets in. Things change!

An agile methodology embraces change, and approaches the project in small incremental steps, exploring, experimenting and adapting as it goes; ...

Saw this article, The Myth of the Interchangeable Programmer. It runs along the lines of the famous Mythical Man Month book by Fred Books, this time applied to off shoring.

Bottom line is that you may find that one developer may be doing 60% of the work of the team, or three developers 80%, and the more people you add to the team, the more you slow down the people who are actually getting something done. The author thinks that from his own experience, a team of eight is the max. I agree. (obviously, for huge projects, you need ...