Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Changing a converted VO application to WPF

Changing a converted VO application to WPF 11 months 1 week ago #1

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:


We add INHERIT Window to the main class name, so it says:

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 obj\Debug 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?


Please Log in or Create an account to join the conversation.

Changing a converted VO application to WPF 11 months 1 week ago #2

  • wriedmann
  • wriedmann's Avatar
  • Away
  • Posts: 1404
  • Karma: 6
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:
using System.Diagnostics

function Start( asCmdLine as string[] ) as int
local oApp as App
oApp := App{}
catch oException as System.Exception
Debug.WriteLine( "error in __ENTITY__ " + oException:ToString() ) 
App.HandleException( oException )
end try
return 0

and the App class contains the following code:
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

AppDomain.CurrentDomain:UnhandledException += AppDomainUnhandledException
oWindow := AppView{}

protect method CloseApplicationHandler() as void

protected static method AppDomainUnhandledException( Sender as object, e as UnhandledExceptionEventArgs ) as void
HandleException( ( Exception ) e:ExceptionObject )
static method HandleException( oEx as Exception ) as void
System.Diagnostics.Debug.WriteLine( oEx:ToString() )
File.AppendAllText( "c:\temp\XSError.log", oEx:Message + CRLF + oEx:StackTrace )

end class

Please remember that I'm using a code only (no XAML) approach for my WPF (MVVM) applications.

Wolfgang Riedmann
Meran, South Tyrol, Italy
This email address is being protected from spambots. You need JavaScript enabled to view it.
www.riedmann.it - docs.xsharp.it

Please Log in or Create an account to join the conversation.

Last edit: by wriedmann.
  • Page:
  • 1