Skip to main content

Posts

Showing posts from October, 2017

Blank/White Image in WPF?

This is a bit of a short post, but in case you are adding an image to a WPF application and it is showing up as blank, make sure that the image is tagged as resource and not as content. Once this change is made, the image should display.

Monitor file system during software install

If you need to get details of what the system impact is from installing a specific program, you can use  InstallWatcher Pro . This software is relatively straight forward and to the point. It doesn't contain any bloatware. Usage is fairly simple. Click snapshot prior to installing the software, follow by analyzing after the installation to view file changes. You can also export the results to html and can then open the html in excel for filtering. Download

Want to cancel resize on a control?

If you are trying to cancel the resize event, it might be more difficult than you had imagined. A lot of the time you will find posts on stack overflow mentioning storing and restoring of the size before and after it resizes. I have two problems with that: 1) it isn't actually canceling the resizing 2) that is not what the user asked for Sadly, canceling the resize event isn't actually possible. At least not in the traditional sense. You can however, override the OnResize event of the control and then not   call the base. 1 2 3 4 protected override void OnResize(EventArgs e) { //base.OnResize(e); } This will for all intents and purposes, cancel the resize event. Even though one cannot cancel the resize event, or so I was told. Maybe you can... Maybe you can't, I don't know. But I bet it won't resize anymore!

Collapse a List into a csv string

If you are tying to turn a list into a single csv (or anything, doesn't have to be a comma), you can use string.join. The following is an example of collapsing a list into a string separated by new lines. 1 2 3 List< string > items = new List< string >(); //populate the list string collapsed = string .Join( ",\r" , items);

Cursors.Wait in WPF?

In WinForms, setting the cursor to Cursors.Wait, and back to Cursors.Default would allow for an hour glass like effect to notify the user that the application is busy. To achieve this with WPF in a quick and dirty way, you can simply override the mouse cursor. 1 2 3 Mouse.OverrideCursor = Cursors.Wait; //code here Mouse.OverrideCursor = null ; Notice, we are setting the cursor to null at the end. This is going to achieve the same thing as Cursors.Default, but the reason we don't use that is because it is using System.Windows.Input.Cursors and not System.Windows.Forms.Cursors and thus there is no .Default. Setting to null results in the cursor going to default... by default.