Simple validation in WPF MvvM Part 2

In a previous post I showed you how to use IDataErrorInfo interface to implement simple validation mechanism in WPF MvvM application. In this post we will try to extend and customize this approach a little. It would be nice I the fields of the form be validated on Save button click. So the user will not see error messages when he opens the for for the first time To achieve that…

By Mirek on (tags: IDataErrorInfo, mvvm, validation, WPF, categories: code)

Simple validation in WPF MvvM using IDataErrorInfo

In this post I will try to demonstrate the simplest validation approach for Windows Presentation Foundation application designed in Model View View-Model pattern. We will be using data binding and IDataErrorInfo implementation. Ok. Let’s assume we have simple data model ProductModel which looks like this So we have Name, Price and Amount text boxes, which we want to bind to the…

By Mirek on (tags: IDataErrorInfo, mvvm, validation, WPF, categories: code)

Parametrized BooleanToVisibilityConverter

Windows Presentation Foundation allows us to create our own value converters and use them in XAML bindings. WPF also comes with a set of predefined converters. One of them is BooleanToVisibilityConverter. It this post I will show you how to create own version of this converter with parameter feature supported. BoleanToVisibilityConverter sets the Visibility value to Visible whe…

By Mirek on (tags: BooleanToVisibilityConverter, IValueConverter, WPF, categories: code)

Because empty tags are bad

Well, not always, but there are times when they are so…what can I do to avoid them. Up to asp.net mvc 3 there’s a problem – if I want to render something wrapped in let’s say a paragraph, but I don’t want that paragraph to appear if the content is empty, then the markup looks like this: That’s a bit verbose. If I skip that check, then an empty hole is rendered on the page so ag…

By on (tags: mvc, categories: code)

Custom WPF check box with inner shadow effect.

Today I will show you how to override the CheckBox control template to style it in custom way and add a sexy looking shadow effect. We want to replace the standard windows checkbox look with something cooler and fit to our application design Windows Presentation Foundation controls are based on Styles and templates. When you want to change the look of the control you have to st…

By Mirek on (tags: CheckBox, inner shadow, styling, WPF, categories: code)

MVC custom validator with client side validation

I wanted to have a reusable email validator since there have been a few cases already where I needed one. Previously I just used the RegularExpressionAttribute but that’s verbose for email. So, without thinking much, I created an attribute that derived from RegularExpressionAttribute and supplied it with a regex I used – that turned out to be a surprise. The server side validat…

By on (tags: mvc, categories: code)

String concatenation and the myths that go with it

I’ve heard a lot of advice about how I should and how I should not concatenate strings. I’ve stuck to them, but the moment of questioning was inevitable. So I spun up a small app to see what’s what. If you’re interested, read along. There have always been moments when I wasn’t sure when to use the “+” operator and when not – in a majority of cases I didn’t cause I’ve always bee…

By on (tags: performance, categories: code)

Support for All()/Any() in WCF Data Services 5.0

9th of April 2012 the new version of WCF Data Services was released with number 5.0 and support for V3 OData protocol. You can download this version from here. You can read more about all new features added to this release of Data Services on WCF Data Services Team Blog Most important features are Vocabularies Actions Spatial types Named streams Patch support Any() All() suppor…

By Mirek on (tags: Data Services, OData, WCF, categories: code)

Practical differences between ASP.NET Web API and WCF Data Services

In this post I would like to point out the main practical differences between ASP.NET Web API and WCF Data Services (OData). For those who does not yet know too much about Web API there is a lot of articles and tutorial about this topic on the net. The starting point is of course Microsoft ASP.NET team site which provides all related information and a bunch of tutorials. Concer…

By Mirek on (tags: ASP.NET, OData, WCF Data Services, Web API, categories: infrastructure, code)

Expanding text area jQuery plugin

Here’s a handy little widget that may be of use. It’s based on this article, with some minor corrections. There’s one bug that I know of at the moment – under IE the text area doesn’t contract. The code is open and you can get it from here. Enjoy…

By on (tags: jQuery plugin, categories: code)