Changing a converted VO application to WPF
Posted: Fri Apr 06, 2018 4:00 am
We've, so far successfully, "xported" a VO app to X#. It's a single window program and we want to replace the VO style window with a WPF window. This is were it becomes tricky. We can add a WPF window, getting a .xaml plus the .xaml.prg file. Then we move the code of the start program to the .xaml.prg file and the compiler says:
Method initializecomponent does not have an implementation
To see what we need, we go to a basic X# WPF program, on top of the Solution Explorer we click the icon Show All Files and the files found there and missing in our program are App.config, App.xaml and App.xaml.prg. We add them (and change the Namespace in the App.xaml.prg to the one used in the converted program). We remove the X#/Vulcan style start method and make sure that the program starts as follows:
PUBLIC CONSTRUCTOR()
InitializeComponent()
We add INHERIT Window to the main class name, so it says:
PUBLIC PARTIAL CLASS WPFScanVenster INHERIT Window
And that's were we get a compiler error:
Error XS0263 Partial declarations of 'WPFScanVenster' must not specify different base classes
The help is not adding much to that (BTW: clicking on the XS0263 link in VS doesn't open anything) - it says Partial declarations of '{0}' must not specify different base classes
A solution wide search does not show anything different than in the basic WPF program. PUBLIC PARTIAL CLASS WPFScanVenster is found another 4 times, in WPFScanVenster.g.prg and WPFScanVenster.g.i.prg, which us duplicated (VS is very good in duplicating) in the Debug and objDebug directory.
How should we proceed from here? Or is there a better way to change a Vo style window based program to a WPF program?
Dick
Method initializecomponent does not have an implementation
To see what we need, we go to a basic X# WPF program, on top of the Solution Explorer we click the icon Show All Files and the files found there and missing in our program are App.config, App.xaml and App.xaml.prg. We add them (and change the Namespace in the App.xaml.prg to the one used in the converted program). We remove the X#/Vulcan style start method and make sure that the program starts as follows:
PUBLIC CONSTRUCTOR()
InitializeComponent()
We add INHERIT Window to the main class name, so it says:
PUBLIC PARTIAL CLASS WPFScanVenster INHERIT Window
And that's were we get a compiler error:
Error XS0263 Partial declarations of 'WPFScanVenster' must not specify different base classes
The help is not adding much to that (BTW: clicking on the XS0263 link in VS doesn't open anything) - it says Partial declarations of '{0}' must not specify different base classes
A solution wide search does not show anything different than in the basic WPF program. PUBLIC PARTIAL CLASS WPFScanVenster is found another 4 times, in WPFScanVenster.g.prg and WPFScanVenster.g.i.prg, which us duplicated (VS is very good in duplicating) in the Debug and objDebug directory.
How should we proceed from here? Or is there a better way to change a Vo style window based program to a WPF program?
Dick