Location of Auto Generated Control_Click Method


(Bob Russell) #1

Not sure that this is the right forum, since I suspect this is a generic Dot Net thing (?) …

I have a WPF project (although not sure that this matters). I add a new form - lets say Login
, and I add a button, named MyButton1.

In my Delphi days, I always liked to keep the Form file code limited to the raw event definitions (e.g. Initialisation, and control events, e.g. OnClick). So the Control OnClick event would just contain the method DoMyButton1OnClick. I would then add a second code file for logic related to the Login form - say MyLoginRoutines.pas. DoMyButton1OnClick would be a method in this second file.

This keeps everything clean (at least for me!)

In my current project, this second file (MyLoginRoutines) is set up with the same class as the Login (OK because the first form had the “Partial” attribute).

Now the problem —

If I select MyButton1 in the designer, and look at the properties/events, then double click on the Click event to generate the event code, that code template is generated in the second MyLoginRoutines.pas file, not in the original Login,xaml.pas file.

Is there any way to force the event to be generated in the original Login.xaml.pas file?

(Or am I doing something stupid anyway?)

Any thoughts welcome.


(marc hoffman) #2

hmm. that seems weird and wrong. just so we get this right, can you send me a small project that shows the exact file structure?


(Bob Russell) #3

I’m happy to send a project, but I’ve just tested on a new minimal project. My steps were:

Create new WPF Oxygene project
Add a button to the Window1 form
Build project
Using Add New Item, create a Class File (Class1.pas)
Add the same Usings as on Window1.xaml.pas plus Implementation and Interface key words
Edit the Type to the same partial class as on Window1

On the designer, double click the button

The click event is generated in the Class1 file.

Everything builds and runs ok, so not a major problem, but would be nice if it kept all the events in Window1 file

I’m running VS2015 and Elements 10.0.0.2285


(RemObjects) #4

Thanks, logged as bugs://80791


(RemObjects) #5

bugs://80791 got closed with status fixed.