Tutorials, tips&tricks, snippets..




Only numbers in a WPF textbox with regular expressions

Managing the input in your project is very important. In this post, you can see how create a numeric field in WPF, using the regular expressions.

Continue reading “Only numbers in a WPF textbox with regular expressions”

Prevent Copy, Cut and Paste in a XAML Textbox

How can you prevent at least one of copy, cut and/or paste actions in a WPF project? Here how prevent these events in a textbox.

Continue reading “Prevent Copy, Cut and Paste in a XAML Textbox”

Disable WPF textbox Cut, Copy and Paste

Sometimes is useful disable the cut, copy and paste functions.

Here how to do it in WPF.
Here the xaml with the parameter extBox CommandManager.PreviewExecuted=“textBox_PreviewExecuted”/>

<TextBox CommandManager.PreviewExecuted="textBox_PreviewExecuted"/>

And here the binded fuction:

private void textBox_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
	if (e.Command == ApplicationCommands.Copy ||
    	e.Command == ApplicationCommands.Cut  ||
    	e.Command == ApplicationCommands.Paste)
		e.Handled = true;

DevExpress: save and restore DataGrid layout using xml file(s)

Using DevExpress tool in very helpful. In this case, I’ve used it for my WPF application. I’m using DevExpress 14.2. After some issues, I am able to save&restore my DataGrid layout with xml files. Continue reading “DevExpress: save and restore DataGrid layout using xml file(s)”

WPF MVVM – Binding command to key press

It can be very helpful to create shortkey in your application. How we can do it in a WPF MVVM application? From the .NET Framework 4, it is easy. Let’s see it and how it works!

Continue reading “WPF MVVM – Binding command to key press”

MVVM and WPF: blink an image from View Model

MVVM pattern design is very powerful, but it is also very complex. This is the main feature of this approach, where UI and business logic are splitted: you will love this feature, but sometimes, you will hate it, because it makes harder all the simply UI operation (also the message box… you can use them, but if you want a 100% MVVM application, you can’t).

In this post I will show you how to make an image blinking from the ViewModel, simply changing the value of a boolean variable.

Continue reading “MVVM and WPF: blink an image from View Model”

SQL Service Query Notifications and their management from a C# application

Think a database notifying you when one of the CRUD operation (CReate, Update and Delete) is made. Think an application taking advantages of it and refresh data in your application in real time. Something like a trigger, but managed from the application code. Think it.. and do it, because you can do it with SQL Server and its Query Notifications.


Binding a List in a WPF ComboBox

I have written how to write a simple WPF application in the MVVM design patter, with and without the DevExpress tools. In this post I’ll show to you an interesting feature: how to bind a list to a ComboBox item in the UI. The good thing is you can use a list of string or anything else custom class, with some attribute to show in the selector.


Creating a MVVM WPF application

I have written a post where I did almost the same thing I’m going to do here, but I used DevExpress tools, now I’ll do it without DevExpress (it isn’t a freeware, so maybe not all people have it).


Powered by

Up ↑