Posts

10 Ways to Create Maintainable and Testable Windows Forms Applications

Most Windows Forms applications I come across have non-existent or extremely low unit test coverage. And they are also typically very hard to maintain, with hundreds if not thousands of lines of code in the code behind for the various Form classes in the project. But it doesn’t have to be this way. Just because Windows Forms is a “legacy” technology doesn’t mean you are doomed to create an unmaintainable mess. Here’s ten tips for creating maintainable and testable Windows Forms applications. I’ll be covering many of these in my forthcoming Pluralsight course on Windows Forms best practices. 1. Segregate your user interface with User Controls First, avoid putting too many controls onto a single form. Usually the main form of your application can be broken up into logical areas (which we could call “views”). You will make life much easier for yourself if you put the controls for each of these areas into their own container, and in Windows Forms, the easiest way to do this is with a Use

WinForms Data Grid – A New Filtering Option

As you can see in the animation below, v21.1 will allow end-users to enter search strings directly within the Grid’s column header. Cannot play video "WinForms Grid - New Filtering Option". Your browser doesn't support embedded videos.

Using Prism modularization in Xamarin.Forms

Image
Prism for Xamarin.Forms 6.2.0 has been released with many notable improvements including a new bootstrapping process, AutoWireViewModel behaviour changes, deep-linking support,  modularity and  Prism template pack  enhancements Today, I fired up Visual Studio to have a play with this new version and decided to try the Xamarin.Forms support for Prism Modules: this is a very useful feature which allows to separate clearly the various parts of the application and improve quality, extensibility and readability of the code. After downloading the new template pack, I created a new solution selecting New Project => Templates => Visual C# => Prism => Forms => Prism Unity App: The new wizard is very useful and permits to select the platforms to target in the project: I selected Android, iOS and UWP and the project was generated targeting the three platforms with a shared PCL. NuGet packages were already updated to the latest version so no need for further actions. While exploring

WPF Multithreading: Using the BackgroundWorker and Reporting the Progress to the UI

 In this blog ,    I am going to show you how to create a multithreaded application that shows a progress dialog which shows real time progress to the user. First lets start with how to get started with multithreading in WPF. If you don’t want to read how this actually works and just want to get the source and start playing ,here is the Running a Background Process The RunWorkerAsync method starts the execution of the background process by raising the DoWork event. The code in the DoWork event handler is executed on a separate thread. int maxRecords = 1000;   BackgroundWorker worker = new BackgroundWorker();   worker.DoWork += delegate ( object s, DoWorkEventArgs args) { for ( int x = 1; x < maxRecords; x++) { System.Threading.Thread.Sleep(10); } };   worker.RunWorkerAsync(); Providing Parameters to the Process Your background process may required one or more parameters, such as the address of a file to download. You can provide a parameter in the RunW