0
Anyone has any idea if it is possible to inherit from the WPF Window class, create some properties and when creating my screens instead of making them inherit from Window make them inherit from this created class ?
An example:
I have a method that loads a list of files in the database; for the screen not to be static I pass the form reference to the method and I change the property that makes Binding with Progressbar as the progress of the operation.
The problem is that this method is used by more than one screen and as the Window class does not have the property of Binding with Progressbar to work the method I need to reference the specific form, the point is that if I have 10 presses using this method I would need to have 10 different calls to it to treat each one individually.
I tried to pass Window as a reference to then get Form Name, but it doesn’t work, does anyone know any other way to do it and/or a way to create an abstract class that I inherited from Window and add the properties I need? So when I went to pass the reference passed this abstract class that would have the properties.
I also tried to pass the property by reference, but Visual Studio says it is not possible to pass a property by reference.
You want to have a default property in all windows. This?
– Jéf Bueno
Exactly.....
– Weslley_51
Well, the part about you having a base class I understood and it works, yes. I just got confused by the example. You have a method that returns a list of objects, this? And then you have in the window a Progress q will update according to the return of this method, this? Is that what you want to make generic? This Progress?
– Aline
No, I have a method that receives a list of files and saves them in the database, the return of it is a class that contains a bool indicating if there was an error and a list of error messages (in case there are errors). Along with the list of files I pass the form and inside my loop that inserts in the database I update the progress of the progressibar, eg: Form.Valuemove = (100 * i ) / Files.Count;
– Weslley_51
And I wanted to generic this property so I could put the generic class as a reference in the signature method and therefore use the independent property of which form I pass.
– Weslley_51