WPF Archive

Rhino error – This object cannot be modified because it is controlled by a document

So it’s been a bit busy recently at work writing up literature review notes, preparing for a visit to Trondheim, Norway, and continuing my research into operational modelling and planning for NHS hospitals. One of the key concepts of the development work I am currently undertaking to solve a research aim is the use of

C# – Getting a list of every ‘color’ from System.Drawing or System.Windows.Media

In C# there are two colour structures in existence for making easy reference to a number of colours without the need to use RGB or Hex codes. However, they tend to be accessible only by typing their name – there isn’t an easy way to simply obtain a random colour from these structures. But if

C# WPF – Convert colour to brush for UI styling

Something that may be occasionally frustrating is trying to quickly colour a UI element on a WPF window programmatically when you know the colour code, or maybe even have a ‘color’ variable storing the colour for you. There can be various ways to do this depending on how you have your colour stored, so this

C# adding reference error – Checking a C++ DLL is valid for a C# project

DLLs compatible with C# projects can either be managed or unmanaged. However, if they’re unmanaged, they cannot be included in the project using the standard References->Add Reference->Browse->OK method, as only managed DLLs can be added in .net applications in this method. To add unmanaged DLLs you need to use a form of DLLImport, which I

Preventing Excel.exe from hanging when using the Microsoft Excel Interop DLL with C#

So it’s been a bit quiet around here recently because I’ve been mostly working on a client project at the office which hasn’t included anything onerous that I felt a quick post would be useful to aid future development. Until now. Part of the work I’ve been completing has included working with Microsoft Excel through

C# WPF – text box is not editable?

In my current work in the c#/WPF environment, I’ve had a need to create a new pop-out window with a load of text boxes and labels programmatically depending on a previous input. However, when I ran the code, the text boxes were not selectable, editable or changeable in any way. They just sat there, visible,

C# GUI – blurring focus on a parent window when using pop-up windows

Continuing with the C# GUI theme of this week (using group boxes, finding UI controls using strings and making child windows stay on top), this post looks at how we can focus a users attention on a new window by blurring the parent. In some cases your software may have an additional window (as a

C# GUI – Make a child window stay on top at all times

Continuing on from my previous work this week (in using group boxes and finding UI controls by name), this post looks at how we can force a child window (such as a pop-up) to stay on top of the main window at all times. This can be particularly useful when you want the new window

C# GUI – Finding controls by name

With a C# GUI created in WPF, you can end up with large amounts of mark-up code in XAML defining your UI, and even more C# controlling the UI behaviours and propagating changes to the back-end. In some cases, you might have twenty controls with similar names. Hard-coding the name of the control each time

C# GUI with WPF – Using Group boxes

A short UI development post today following some work I’ve completed on building a new GUI for a project at work. Hopefully this post gives a brief introduction to those wanting to also use group boxes to group content, and how to resolve the issue where using group boxes may give you the error “The