Driver Introspection with DriverMon

Saturday, November 18, 2017

In the past few weeks I've been working in my non-existent spare time on DriverMon - a driver monitoring tool for Windows. The tool is far from complete, but it's already quite useful. In this post I'll describe how to use it and some of the challenges of building such a tool. Initially I wanted to be able to track every I/O Request Packet (IRP) targeted to monitored devices. The term "devices" here is important, as the Windows I/O system is device-centric rather than driver-centric. That is, requests are delivered to devices, not drivers. A device can be thought of...
no comments

Color Gradient Generator

Tuesday, November 12, 2013

A while back, I created a WPF Mandelbrot Set program with zoom abilities. I demonstrated the use of async/await for writing code that works asynchronously (to keep the UI responsive), but is easy to write as synchronous code. Here’s a sample image:The image is grayscale, so I wanted to make it use colors, to indicate the level of “being part of” the Mandelbrot set. The problem here is how to create a nice color gradient that moves smoothly from color to color.One possible option might be to leverage an existing class, such as WPF’s LinearGradientBrush, set up a bunch...

MVVM View vs. Control

Sunday, November 3, 2013

In the MVVM world, Views are attached to ViewModels. How can a view be implemented? Typical answers for say, WPF, are: Window, User Control and Data Template. Similar answers exist for Windows Phone and Windows 8, where “Window” may be dropped or replaced by Page.This is certainly true, but about that User Control? Can any user control automatically be considered a View? Not quite.The distinction between view and control (user control or otherwise) is based on reusability and dependency. A View requires a ViewModel to give it context. A View cannot function without a ViewModel. Typical XAML View would...
no comments

XAML as DSL

Sunday, May 5, 2013

About 3 years ago, when .NET 4 and Visual Studio 2010 were just released, I’ve blogged (part 1, part 2) about the changes that took XAML from its WPF inception to the System.Xaml namespace and System.Xaml.Dll assembly, to be available more generally, not just for WPF. I’ve shown that XAML is just a declarative way of creating objects, setting their properties – sometimes in interesting ways. I did promise at the end of that second post that I’d show how to use attached properties, but never did have the time to deliver. 3 years later, it’s high time I...
one comment

XAML Tip: Graphics with ItemsControl

Saturday, February 23, 2013

Sometimes in a WPF or Windows Store or Windows Phone application we need to draw some things based on some collection of data items. Suppose we have the following simple data item: class CarData { public double Distance { get; set; } public string Image { get; set; }}Suppose we have a collection of CarData objects, and the requirement was to show a set of images along a line with a particular distance, like in the following screenshot:The distance from the left is determined by the Distance property, and the image is determined by...

Preview of Blend 5 available

Tuesday, December 25, 2012

When Visual Studio 2012 came out, one thing was sorely missing. An Expression Blend tool that can handle WPF 4.5 applications. Blend for Visual Studio that is currently available only supports Windows 8 Store Apps, but not WPF (or Silverlight).A few days ago, Microsoft released a preview of Blend 5 (with Sketchflow), that’s able to work with WPF and Silverlight, along with Windows 8 Store apps.The tool can be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=30702Microsoft stated that the final version of the tool will be available with Update 2 of Visual Studio 2012 (Update 1 was released about 2 weeks ago).
no comments

My WPF book has been published

Friday, September 28, 2012

My book, WPF 4.5 Cookbook has just been published by Packt Publishing. As an added bonus, Packt publishing is celebrating its 1000th title, and all those with registered accounts at Packt, and those who register by the 30th (2 days to go), will be able to select a free e-book from all published books. If that not enough, Packt provides a free 7-day access to its PacktLib book library.Go over to this link and log in or create an account, and claim your free e-book!
tags: ,
no comments

WPF 4.5: Accessing bound collections on non UI threads

Saturday, July 21, 2012

The single threaded behavior of WPF (and other UI technologies) requires that anything tied to the user interface be manipulated on the UI thread, incuding data bound objects. There are several ways to do that, assuming the code is on a non-UI thread, such as using Dispatcher.(Begin)Invoke, capturing and using the current SynchronizationContext, etc.Specifically, if some collection is data bound, items cannot be added or removed from it from a non-UI thread. WPF 4 (and earlier) throws an exception, because the data binding mechanism expects to be notified of changes (e.g. ObservableCollection<T>) on the UI thread.One of the improvements...
no comments

Windows 8 Metro: Detecting scroll changes in ListView

Monday, July 2, 2012

I had a requirement in a Metro app I’m working on to detect scrolling in a ListView (GridView is practically the same), or more precisely, detect whether the selected item goes off the visible ListView area, and if so, switch some items in the ListView so that the selected item be visible again; this is not an entirely accurate description, but it’s close enough for our purposes. An easy one, right?Searching the ListView class (and its bases) yields no useful results on scrolling. In WPF, the ScrollViewer element has an attached event, ScrollChanged. This can be used (in WPF)...

WPF Tip: Attached properties and bindings

Saturday, May 12, 2012

Attached properties are a great way to extend capabilities of existing elements without the need to derive or otherwise tinker with those elements. Suppose we create an attached property that is a collection of objects of some particular kind. When that property changes, those objects are read, and that special functionality is applied. Here’s a hypothetical example of such a scheme: public static class SomeHelper {     public static DemoCollection GetData(DependencyObject obj) {         return (DemoCollection)obj.GetValue(DataProperty);     }       public static void SetData(DependencyObject obj, DemoCollection value) {         obj.SetValue(DataProperty, value);     }       public static readonly DependencyProperty DataProperty =          DependencyProperty.RegisterAttached("Data",...
tags: , , ,
one comment