I’m currently writing a HMI for an automated machine in VB.Net 2010. I have a custom class that turns a Border green or red depending on the value of an input on a remote I/O module.
The connection to the remote I/O module is through a COM object provided by the manufacturer. I have three remote connections, lets’ call them g1, g2, and g3. They’re of type Manufacturer.ConnectionObject.
I would like to specify, using a property that I can set in XAML, that instances of MyCustomBorder use g1, g2, or g3. Unfortunately, setting up a Property called g and typing ‘g1’ into the property field results in the message “Property value is not valid. Details: Property ‘g’ does not support String to Value conversion.”
So, instead, I am left to manually set (during program startup), every single instance of MyCustomBorder:
CustomBorder1.g = g1
CustomBorder2.g = g3
CustomBorder73.g = g1
… and so on.
I am told I need to implement a converter between String and the custom class, Manufacturer.ConnectionObject, but I have no idea how to accomplish this, especially since Manufacturer.ConnectionObject is part of a closed-to-me COM object.
Help, anyone? Thanks!
Trying to directly bind a COM object into WPF is likely just going to cause you a lot of headaches. As a first step I would define a WPF friendly class which wraps instances of
Manufacturer.ConnectionObjectand bind that instead to WPF