Understanding WPF

This forum is meant for anything you would like to share with other visitors
Post Reply
Terry
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Understanding WPF

Post by Terry »

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
Attachments
Understanding WPF.pdf
(122.19 KiB) Downloaded 35 times
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Understanding WPF

Post 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
SelectWindow.png (48.53 KiB) Viewed 354 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Terry
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Understanding WPF

Post by Terry »

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
User avatar
wriedmann
Posts: 3644
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Understanding WPF

Post 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
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Understanding WPF

Post 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 ;-?
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
Terry
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Understanding WPF

Post by Terry »

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
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Understanding WPF

Post 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
Terry
Posts: 306
Joined: Wed Jan 03, 2018 11:58 am

Understanding WPF

Post by Terry »

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
Post Reply