I am aware that some here are trying to get to grips with WPF. It allows unparalleled flexibility and capability when designing a UI screen.
It may initially appear difficult to understand.
I have attached a short pdf which, hopefully, will help some.
If I have made any stupid mistakes I would be grateful if you would let me know.
Terry
Understanding WPF
Understanding WPF
- Attachments
-
- Understanding WPF.pdf
- (122.19 KiB) Downloaded 74 times
Understanding WPF
Hi Terry,
one of the most important things when designing WPF windows and controls is that not only containers can contain other containers, but also controls like buttons can host containers - so you can put a Grid or a StackPanel to a button or also in a ListView item, if you like.
This window uses a Grid, and in one of the cells a StackPanel. The single controls of the StackPanel are all Pushbuttons (to react to key and mouse button press), and every pushbutton hosts a Grid that contains an Image and a TextBlock - and all that is entirely datadriven, using MVVM.
That opens up an entire new world of GUI design.
Wolfgang
one of the most important things when designing WPF windows and controls is that not only containers can contain other containers, but also controls like buttons can host containers - so you can put a Grid or a StackPanel to a button or also in a ListView item, if you like.
This window uses a Grid, and in one of the cells a StackPanel. The single controls of the StackPanel are all Pushbuttons (to react to key and mouse button press), and every pushbutton hosts a Grid that contains an Image and a TextBlock - and all that is entirely datadriven, using MVVM.
That opens up an entire new world of GUI design.
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
Understanding WPF
Hi Wolfgang
Yes I agree. Perhaps that should be added to the pdf.
But the Question I would ask is how far do you go for someone who is totally new to WPF.
Button content is an Object can indeed host any other Object such as a Container which is also an object.
My thinking was if we get into that chain (MVVM etc) it cold become too overwhelming too soon.
But it's certainly worth mentioning, as you have done, at this stage.
What do you think?
Terry
Yes I agree. Perhaps that should be added to the pdf.
But the Question I would ask is how far do you go for someone who is totally new to WPF.
Button content is an Object can indeed host any other Object such as a Container which is also an object.
My thinking was if we get into that chain (MVVM etc) it cold become too overwhelming too soon.
But it's certainly worth mentioning, as you have done, at this stage.
What do you think?
Terry
Understanding WPF
Hi Terry,
even if WPF works better when used with the MVVM paradigm, that goes far beyond someone new to WPF can understand.
I would add that WPF add a lot of graphical possibilities, and makes it really, really easy to build own controls that are only a composition of other basic controls.
Wolfgang
even if WPF works better when used with the MVVM paradigm, that goes far beyond someone new to WPF can understand.
I would add that WPF add a lot of graphical possibilities, and makes it really, really easy to build own controls that are only a composition of other basic controls.
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
Understanding WPF
It would habe been easier, if they had choosen a clearer wording.
- "Everything" is a "control"
- controls can contain controls
- controls have properties and capabilities to act and react.
Did i miss something ;-?
- "Everything" is a "control"
- controls can contain controls
- controls have properties and capabilities to act and react.
Did i miss something ;-?
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Understanding WPF
Hi Karl
You write: Did i miss something ;-?
I don't know. But Everything is an Object. Controls are Objects.
- cobjects can contain objects.
- objects have properties and capabilities to act and react.
More or less what you said and principles of OOP.
Clearer wording? I'd probably agree in this context. But we all think differently and maybe clearer wording to me would not be clearer wording to you.
Regards
Terry
You write: Did i miss something ;-?
I don't know. But Everything is an Object. Controls are Objects.
- cobjects can contain objects.
- objects have properties and capabilities to act and react.
More or less what you said and principles of OOP.
Clearer wording? I'd probably agree in this context. But we all think differently and maybe clearer wording to me would not be clearer wording to you.
Regards
Terry
Understanding WPF
Hello Terry, Karl, Wolfgang,
There is a lot you can do based on much WPF XAML and not even so much "code behind". I recommend to check out these programs to be amazed. Even though these are old, they still work, for the 2nd you may need to remove the Signing certificate and agree to a higher .Net version.
Horse Race:
https://www.codeproject.com/Articles/18 ... art-1-XAML
Baby Smash:
https://www.hanselman.com/blog/introduc ... experiment
This having said, it is often difficult to predict what happens on viewing your screens when content is added in stackpanels or dockpanels. On the other hand, you can still design a screen much the way you did in VO and also enter a value without MVVM/databinding, by directly addressing the name of the control, so also just like in VO
Dick
There is a lot you can do based on much WPF XAML and not even so much "code behind". I recommend to check out these programs to be amazed. Even though these are old, they still work, for the 2nd you may need to remove the Signing certificate and agree to a higher .Net version.
Horse Race:
https://www.codeproject.com/Articles/18 ... art-1-XAML
Baby Smash:
https://www.hanselman.com/blog/introduc ... experiment
This having said, it is often difficult to predict what happens on viewing your screens when content is added in stackpanels or dockpanels. On the other hand, you can still design a screen much the way you did in VO and also enter a value without MVVM/databinding, by directly addressing the name of the control, so also just like in VO
Dick
Understanding WPF
Hi Dick
Yes I agree amazing things can be done using Xaml.
But learning it takes time that could be spent learning something else.
It was just my personal opinion that it was quicker to progress up the learning curve by following a "quick coding route". with Xaml coming later.
Xaml first may prove quicker for some. As with anything else in programming it is all trade-offs. Nothing is real;y black or white.
Regards
Terry
Yes I agree amazing things can be done using Xaml.
But learning it takes time that could be spent learning something else.
It was just my personal opinion that it was quicker to progress up the learning curve by following a "quick coding route". with Xaml coming later.
Xaml first may prove quicker for some. As with anything else in programming it is all trade-offs. Nothing is real;y black or white.
Regards
Terry