Converting a c# WPF Diagramming Project into vb.net

I was looking for an overview on how to create a WYSIWYG layout editor for a project I’m working on. Found something ideal, with the remaining small task of converting it into vb.net…

The setup’s complicated. I’m creating a winforms project, but I need advanced graphics capabilities that I can only get through WPF (via integrating WPF custom controls into my winforms app). Now, I’m only just getting started on WPF so the task of converting a c# wpf project into a vb one was quite difficult. VB.net version download:

The original article is here:

https://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part-1

I’d urge you to download it and have a look at the different project stages. I used this code as the basis for my conversion. Here’s some notes on the conversion:

There was a really annoying exception preventing compile, giving me some kind of ‘can’t find in namespace’ error. Appears to be an annoying intermittent thing with VisualStudio:

https://stackoverflow.com/questions/15051121/the-name-does-not-exist-in-the-namespace-clr-namespace

I think the thing that did it for me was changing the Target CPU in the Project Compile menu. Then I got an error saying CPU mismatch and when changed back, the error was fixed.

It could have also been changing the namespace in the top level element of the form:

There were a couple of challenging bits to the conversion. Firstly, most online code converters missed the AddHandler conversion. For example:

converted into:

The resolved code being:

Also, one particularly tricky conversion:

converted into:

which was way off (IValueConverter being the culprit). Final working code:

For completeness, another thing I had to do was Must import reference UIAutomationProvider.dll from:

Enjoy!

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*