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
Changing a converted VO application to WPF
Changing a converted VO application to WPF
Hi Dick,
I would go the other way: build a new WPF application and add the functionalities from your VO program.
Otherwise it could be a nightmare.
I'll do a similar thing with my applications.
But you don't need any XAML file in a WPF program to get it worked.
My WPF programs have the following start() function:
and the App class contains the following code:
Please remember that I'm using a code only (no XAML) approach for my WPF (MVVM) applications.
Wolfgang
I would go the other way: build a new WPF application and add the functionalities from your VO program.
Otherwise it could be a nightmare.
I'll do a similar thing with my applications.
But you don't need any XAML file in a WPF program to get it worked.
My WPF programs have the following start() function:
Code: Select all
using System.Diagnostics
[STAThreadAttribute];
function Start( asCmdLine as string[] ) as int
local oApp as App
try
oApp := App{}
oApp:Run()
catch oException as System.Exception
Debug.WriteLine( "error in __ENTITY__ " + oException:ToString() )
App.HandleException( oException )
end try
return 0
Code: Select all
using System
using System.Collections.Generic
using System.Configuration
using System.Windows
using System.IO
class App inherit Application
protected virtual method OnStartup( e as StartupEventArgs ) as void
local oWindow as AppView
super:OnStartup(e)
AppDomain.CurrentDomain:UnhandledException += AppDomainUnhandledException
oWindow := AppView{}
oWindow:Show()
return
protect method CloseApplicationHandler() as void
self:Shutdown(0)
return
protected static method AppDomainUnhandledException( Sender as object, e as UnhandledExceptionEventArgs ) as void
HandleException( ( Exception ) e:ExceptionObject )
return
static method HandleException( oEx as Exception ) as void
System.Diagnostics.Debug.WriteLine( oEx:ToString() )
File.AppendAllText( "c:tempXSError.log", oEx:Message + CRLF + oEx:StackTrace )
return
end class
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it