InvokeCommandAction with EventArgs as Command Parameter

WPF Playground

Expression Blend team provides the ability to wire up some events to viewmodel through commands like SelectionChanged of a ListBox, etc using System.Windows.Interactivity.dll. You can bind a Command to any event with WPF controls. There is also a way to bind command parameter also, so that view state can passed to the viewmodel.

View original post 134 more words


using SQLite with Entity Framework 6 and the Repository Pattern

Software Engineering

In this post, a Data access layer is implemented using the repository pattern together with entity Framework 6 and SQLite as a database. The post continues on from Getting started, using SQLite with .NET

UPDATE 02.03.2014: Using the new SQLite version now with the SQLite provider. The xml app configuration needs to be changed due to this. Updated all other NuGet packages as well.

UPDATE 02.07.2014: Using the new SQLite version now with the SQLite provider. The xml app configuration needs to be changed due to this. Updated all other NuGet packages as well.


A SQLite database can be created using the Firefox addon.

Application data can then be added directly using this tool:

The .sqlite file is added to the project and ‘copied if newer’ when built.

OLD no longer required, but still works
The required NuGet packages need to be added. (At present…

View original post 215 more words

Adding right-aligned row numbers to a DataGridRowHeader in WPF

Magnus Montin

This post provides an example of how you can right-align or centre the text in a DataGridRowHeader in a DataGrid in WPF using Visual Studio 2012 or later. It also explains how you can display the correct row numbers in the DataGridRowHeader and automatically update these as you are adding or removing items to and from the DataGrid’s ItemsSource collection dynamically.


The DataGrid control has a RowHeaderTemplate property that defines the DataTemplate for the DataGridRowHeader. A DataGridRowHeader is by default displayed to the left of the left-most data column on each row in the DataGrid. It doesn’t scroll horizontally with the rest of the columns and is usually used to display some additional information that associated with a specific row, for example a row number.

The RowHeaderTemplate DataTemplate doesn’t inherit the data context from the DataGridRow but since it gets added to the visual tree, you can use a…

View original post 777 more words

Data validation in WPF

Magnus Montin

A common requirement for any user interface application that accepts user input is to validate the entered information to ensure that it has the expected format and type for the back-end to be able to accept and persist it. This post is about how data validation works in WPF and the different validation options there are available including implementing custom ValidationRules and using the IDataErrorInfo interface and the INotifyErrorDataError interface that was introduced in the .NET Framework 4.5. It also contains an example that shows how you can validate data using data annotations.

Data binding

In a typical WPF application that uses the MVVM (Model-View-View Model) design pattern, a dependency property of a user interface control in a XAML-defined view uses data binding to bind to some data returned by a CLR property of the view model. If the binding is setup correctly and the view model implements the System.ComponentModel.INotifyPropertyChanged

View original post 2,773 more words

Prism Splash Screen Module

eagleboost's Blog

Splash screen is a good thing. It makes your application looks professional while numbers of libraries are being loaded in the background, mean while, users may feel the loading time is actually not that long if they see something updating. So the way we designing a splash screen is indeed very important in terms of a good one.

There’re various ways you can find everywhere to implement a splash screen but very few of them meet my criteria of good ones:

  • A splash screen should provide status updating to prove the application is not hung
  • A splash screen should show as the first visual of the application, especially, the main window should only be visible after the splash screen is gone – which means the initialization process has finished
  • A splash screen should be interactable – Some applications like to show splash screen as topmost – users can’t bring their…

View original post 496 more words

Zoomable autosizing canvas in WPF

Ira Lukhezo's blog

I have created a control for a project I am working on that uses a canvas to draw graph ticks for a custom scale, but ran into the limitation of the canvas control where child items are not scaled accordingly when the height (or width) of the canvas changes. Luckily, this is quite a straightforward problem to fix, but I just could not seem to find either the correct search terms to enter in Google or locating code samples in books that demonstrated how to resolve the issue. I have just knocked this code up this afternoon so it is not perfect, but should suffice should you require something similar.



In order to resolve the problem you will need to create a custom canvas and override both MeasureOverride and ArrangeOveride incorporating any custom logic you require in these methods.

using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
namespace AutosizingCanvasApp.Controls

View original post 985 more words