Page 1 of 1
Understanding WPF
Posted: Wed Jul 21, 2021 12:44 pm
by TerryB1
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
Posted: Wed Jul 21, 2021 1:07 pm
by wriedmann
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
- SelectWindow.png (48.53 KiB) Viewed 704 times
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
Understanding WPF
Posted: Wed Jul 21, 2021 2:25 pm
by TerryB1
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
Understanding WPF
Posted: Wed Jul 21, 2021 2:28 pm
by wriedmann
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
Understanding WPF
Posted: Wed Jul 21, 2021 2:30 pm
by FFF
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 ;-?
Understanding WPF
Posted: Wed Jul 21, 2021 3:52 pm
by TerryB1
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
Understanding WPF
Posted: Wed Jul 21, 2021 6:09 pm
by ic2
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
Understanding WPF
Posted: Thu Jul 22, 2021 8:50 am
by TerryB1
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