WPFAQS – Logical and Visual Trees in WPF

WPFAQS – is a series on WPF frequently asked questions (FAQS). Today we will discuss about one of the most important and mostly overlooked areas of WPF, Logical and Visual trees.

WPFAQS(002) – What are logical and visual trees in WPF?

One of the main reason of adaptation of WPF by the developers is that it has an inherent support of “separation of concerns”, like the domain/model and its presentation in the form of user interfaces or views. How it is achieved is by introducing two new concepts apart from lots of others – logical trees and visual trees and they are based on a very powerful concept of composition, that means the developers/designers can now compose these trees as they want. “WOW” cool stuff right. First thing first, lets discuss the WPF trees and there types, logical and visual trees. Trees is the basic data structure behind XAML and WPF composition model. When you compose an application with the existing controls or your own custom controls to create your application this means you are creating a logical tree of the controls. Not clear?? I know its a little bit involved to get a hold of it. Let me give you an example – I  have created a very simple application of drawing random blocks, called “LegoDraw”  Here is how it looks like.

CapturedImage-Geeks

And now if you look at the logical tree below, of  this application, you notice that The Window is composed of a grid control that is further composed of Menus and Stackpanel and that further composed of comoboboxes and another Grid, that actually contains a Mainboard user control.

 

Pic1

This logical tree can now very easily map to the XAML hierarchal view. What are the benefits of using this type of composition. The benefits will become more obvious when you understand the design pattern behind this data structure that is the famous composite design pattern. That mean you are creating a parent child relationship where children knows their parents and the parent knows the where about of their children. So what does it mean, It means that parents can iterate through the children as defined in the strategy and controlling their layouts etc etc.

Lets now talk about the deferred discussion of look and feel, actually i was waiting for this moment. The logical tree is great in defining controls by composing them etc, etc. but limited to some default look and feel – as provided by the framework or so. How about I don't need a rectangular button instead i need a circular button, what are the options we have in this case??? We have limitless options available with the introduction of visual tree. A visual tree is basically a mare expansion of a logical tree, where the child nodes/elements that are derived from “System.Windows.Media.Visual or System.Windows.Media.Visual3D “ are broken down into their core visual components, known as visual tree. That's the foundation of the template mechanism provided in the WPF, that is, when you write a template for a control, you are defining or redefining the visual tree that applies for that control. Here is an example of a Template of a combobox apart from lots of other things that you can redefine for its appearance.

Pic2

The visual tree provides you extreme level of control in composing different types of controls, when it comes to performance and  optimization  or even defining the event routing strategy between the parents and the child controls. You can also read more details about them here[Ms001]

That's all for now folks, will discuss next time the different types of templates with some examples. See you next time, Enjoy :)

If you enjoyed reading this blog, leave your valuable feedback and consider subscribing to the RSS feed. You can also subscribe to it by email. Also, you can follow me on Twitter. Thank you!

Comments (2) -

legal anabolic steroids
12/8/2017 4:16:53 AM #

Adkinson NF, et al. Glucocorticosteroids.  Here is my web page ...  legal anabolic steroids - https://steroids-canada.ca

what is windows vps server
12/10/2017 7:57:57 PM #

best mobile site hosting  web hosting services what is - www.buena.space/web-hosting-services-what-is.html  wordpress host files for download  vps hosting xen - https://www.buena.space/vps-hosting-xen.html  unlimited ssd reseller hosting  what does vps hosting mean - www.buena.space/what-does-vps-hosting-mean.html  virtual private server hosting india  web form hosting - https://www.buena.space/web-form-hosting.html  web page host  website hosting design - www.buena.space/website-hosting-design.html  website hosting services in kenya  cheap windows vps 1gb ram - www.buena.space/cheap-windows-vps-1gb-ram.html  free host for wordpress  cheap dedicated servers with cpanel - www.buena.space/...icated-servers-with-cpanel.html  dedicated server hong kong  free reseller account hosting - www.buena.space/free-reseller-account-hosting.html  wordpress hosts file  cheap usa vps unlimited bandwidth - www.buena.space/...sa-vps-unlimited-bandwidth.html  cheap good  what is windows vps server - www.buena.space/what-is-windows-vps-server.html  vps  web and email hosting malaysia - www.buena.space/...and-email-hosting-malaysia.html  web hosting prices india  dedicated server ip address - www.buena.space/dedicated-server-ip-address.html  cheapest linux vps server  wordpress cheap hosting - www.buena.space/wordpress-cheap-hosting.html  best music hosting site  dedicated game server - https://www.buena.space/dedicated-game-server.html  best vps server for wordpress  unlimited bandwidth vps hosting - www.buena.space/...ited-bandwidth-vps-hosting.html  dedicated server offer  dedicated server windows vs linux - www.buena.space/...ed-server-windows-vs-linux.html  simple wordpress hosting  virtual private servers hosting - www.buena.space/...al-private-servers-hosting.html  web and email hosting philippines  dedicated server providers list - www.buena.space/...ated-server-providers-list.html  free hosting site with ftp  vps managed - https://www.buena.space/vps-managed.html  cheapest dedicated servers uk  best hosting for wordpress sites uk - www.buena.space/...ing-for-wordpress-sites-uk.html  best domain hosting wordpress  half-life dedicated server update tool - www.buena.space/...dicated-server-update-tool.html  dedicated hosting solution  windows 7 vps usa - https://www.buena.space/windows-7-vps-usa.html  web hosting cheapest  buy dedicated server cheap - www.buena.space/buy-dedicated-server-cheap.html  vps email hosting  web hosting services sql server 2008 - www.buena.space/...g-services-sql-server-2008.html  website hosting uk costs  linux master reseller hosting - www.buena.space/linux-master-reseller-hosting.html  website hosting plans in india  moving wordpress to new hosting - www.buena.space/...g-wordpress-to-new-hosting.html

vps vs shared hosting
12/10/2017 10:39:58 PM #

best linux hosting reseller  vps server germany windows - www.albertha.club/vps-server-germany-windows.html  shared hosting packages  don't starve together caves dedicated server setup - www.albertha.club/...s-dedicated-server-setup.html  web hosting providers reviews  windows vps unmetered bandwidth - www.albertha.club/...-vps-unmetered-bandwidth.html  website hosting in china  ssd shared hosting europe - www.albertha.club/ssd-shared-hosting-europe.html  free wordpress domain hosting  best host for wordpress blog - www.albertha.club/...-host-for-wordpress-blog.html  web hosting  vps vs shared hosting - www.albertha.club/vps-vs-shared-hosting.html  dedicated server  web hosting in pakistan lahore - www.albertha.club/...sting-in-pakistan-lahore.html  cheap europe vps  semi dedicated hosting - www.albertha.club/semi-dedicated-hosting.html  best shared hosting for laravel  web hosting customer support - www.albertha.club/...hosting-customer-support.html  good wordpress hosting uk  best windows vps reseller - www.albertha.club/best-windows-vps-reseller.html  cheapest vps with cpanel  virtual dedicated server buy - www.albertha.club/...ual-dedicated-server-buy.html  unlimited master reseller hosting india  dedicated server price - www.albertha.club/dedicated-server-price.html  best hosting provider for wordpress  resellers hosting - https://www.albertha.club/resellers-hosting.html  whm reseller hosting cheap  web hosting top 10 australia - www.albertha.club/...hosting-top-10-australia.html  web hosting sydney reviews  virtual host for wordpress - www.albertha.club/virtual-host-for-wordpress.html  unmanaged dedicated server uk  how to transfer wordpress site to new host and domain - www.albertha.club/...e-to-new-host-and-domain.html  fully managed windows vps  cpanel dedicated server license - www.albertha.club/...dedicated-server-license.html  web hosting mailing list  moving wordpress to another hosting - www.albertha.club/...press-to-another-hosting.html  cheap vps hosting sweden  web hosting for students review - www.albertha.club/...ting-for-students-review.html  best affordable vps hosting  moving drupal site to new host - www.albertha.club/...-drupal-site-to-new-host.html  free hosting wordpress  best dedicated server australia - www.albertha.club/...dicated-server-australia.html  shared hosting ssh access  web host vs domain name - www.albertha.club/web-host-vs-domain-name.html  best fully managed dedicated server  does wordpress do email hosting - www.albertha.club/...rdpress-do-email-hosting.html  web hosting reviews uk based  vps windows server usa - www.albertha.club/vps-windows-server-usa.html  hosted email reseller  best site to host videos - www.albertha.club/best-site-to-host-videos.html  us vps server  web hosting unlimited email accounts - www.albertha.club/...unlimited-email-accounts.html

cheap vps game server  web hosting service providers in bangalore - www.cassey.space/...ce-providers-in-bangalore.html  free wordpress site hosting  vps server uk - https://www.cassey.space/vps-server-uk.html  free hosting wordpress  best cheapest vps - https://www.cassey.space/best-cheapest-vps.html  cheapest uk vps  linux vps hosting uk - https://www.cassey.space/linux-vps-hosting-uk.html  cheap domain hosting sites  web hosting solution logistics provider and a crm - www.cassey.space/...istics-provider-and-a-crm.html  cheap vps server windows  web hosting server specifications - www.cassey.space/...ing-server-specifications.html  free windows dedicated server hosting  web hosting coupons - https://www.cassey.space/web-hosting-coupons.html  dedicated server  free vps hosting canada - www.cassey.space/free-vps-hosting-canada.html  website email hosting services  reseller hosting uk cpanel - www.cassey.space/reseller-hosting-uk-cpanel.html  web & email hosting  wordpress hosting low cost - www.cassey.space/wordpress-hosting-low-cost.html  10gbps unmetered dedicated server  web hosting with ssl included - www.cassey.space/...hosting-with-ssl-included.html  plesk vps hosting  south korea dedicated server - www.cassey.space/south-korea-dedicated-server.html  import wordpress to new host  cheap offshore vps - https://www.cassey.space/cheap-offshore-vps.html  best unmetered dedicated server  top 10 cheap reseller hosting - www.cassey.space/...10-cheap-reseller-hosting.html  best hosting site for wordpress blog  best vps hosting providers india - www.cassey.space/...s-hosting-providers-india.html  best vps service in india  web hosting new york - https://www.cassey.space/web-hosting-new-york.html  cheap wordpress hosting pakistan  difference between dedicated server mode and shared server mode - www.cassey.space/...de-and-shared-server-mode.html  cheap dedicated server eu  vps for windows 7 - https://www.cassey.space/vps-for-windows-7.html  website hosted in china  dedicated server auction - www.cassey.space/dedicated-server-auction.html  ubuntu server vps setup  linux vps server - https://www.cassey.space/linux-vps-server.html   how to host my wordpress blog on my own domain - www.cassey.space/...ess-blog-on-my-own-domain.html   hosting linux vps - https://www.cassey.space/hosting-linux-vps.html  hosting vps fast  low end dedicated server - www.cassey.space/low-end-dedicated-server.html  the best dedicated server  managed vps server hosting - www.cassey.space/managed-vps-server-hosting.html  web hosting multiple domains  best wordpress optimized hosting - www.cassey.space/...rdpress-optimized-hosting.html  web hosting macintosh  web hosting plans india - www.cassey.space/web-hosting-plans-india.html

dedicated server renting
12/11/2017 9:13:26 AM #

web store hosting reviews  web hosting space charges - www.buena.space/web-hosting-space-charges.html  web hosting in rawalpindi  web hosting support ms access - www.buena.space/web-hosting-support-ms-access.html  website hosting in chennai  best master reseller hosting - www.buena.space/best-master-reseller-hosting.html  website domain and hosting packages  web design hosting and maintenance - www.buena.space/...gn-hosting-and-maintenance.html  cheap australia vps hosting  website hosting with database - www.buena.space/website-hosting-with-database.html  best linux vps  cheap windows vps australia - www.buena.space/cheap-windows-vps-australia.html  hosting shared server  best european vps hosting - www.buena.space/best-european-vps-hosting.html  wordpress hosting service  instant dedicated server - www.buena.space/instant-dedicated-server.html  cheap vps server uk  vps hosting unlimited bandwidth - www.buena.space/...osting-unlimited-bandwidth.html  vps hosting reviews  vps uk cheap - https://www.buena.space/vps-uk-cheap.html  web hosting services brisbane  colocation dedicated server - www.buena.space/colocation-dedicated-server.html  web hosting windows server  free hosting no ads unlimited bandwidth - www.buena.space/...no-ads-unlimited-bandwidth.html  virtual private servers windows  best usa vps hosting - https://www.buena.space/best-usa-vps-hosting.html  web developer reseller hosting  west coast dedicated server - www.buena.space/west-coast-dedicated-server.html  dedicated server europe  best hosting sites for wordpress uk - www.buena.space/...ing-sites-for-wordpress-uk.html  web hosting best support  web hosting offers - https://www.buena.space/web-hosting-offers.html  free domain name and hosting with wordpress  reseller hosting with whmcs - www.buena.space/reseller-hosting-with-whmcs.html  web hosting pay monthly  change wordpress host database - www.buena.space/...ge-wordpress-host-database.html  free blog sites list in india  dedicated server reseller whmcs - www.buena.space/...ated-server-reseller-whmcs.html  website hosting costs uk  cheap vps 100gb - https://www.buena.space/cheap-vps-100gb.html  virtual private servers hosting  web hosting zimbabwe - https://www.buena.space/web-hosting-zimbabwe.html  move wordpress to new domain same host  low cost windows vps hosting - www.buena.space/low-cost-windows-vps-hosting.html  best  dedicated server renting - www.buena.space/dedicated-server-renting.html  servers in india  reseller dedicated server - www.buena.space/reseller-dedicated-server.html  web design and hosting nottingham  web site hosting uk - https://www.buena.space/web-site-hosting-uk.html  wordpress windows or linux hosting  best affordable wordpress hosting - www.buena.space/...fordable-wordpress-hosting.html

in vitro fertilization cost in india
12/13/2017 4:04:52 AM #

Therefore, it offers a considerable cost savings over solar panels if you're building a new home.  Here is my website;  in vitro fertilization cost in india - www.tuscancountrystore.com/.../171732

Kuliah teknik sipil Kelas karyawan
12/13/2017 11:37:18 AM #

It's going to be end of mine day, however before ending I am reading this enormous post to increase my know-how.   mata kuliah hi - erlangga.staff.gunadarma.ac.id/.../...n+Ilmiah.pdf   Also visit my blog  Kuliah teknik sipil Kelas karyawan - http://nuri.staff.gunadarma.ac.id/Publications

Helpful info. Fortunate me I found your website by chance, and I'm shocked why this accident did not came about in advance! I bookmarked it.

bathmate hydro pump youtube
12/15/2017 9:48:18 AM #

Greetings, There's no doubt that your website might be having web browser compatibility problems. When I take a look at your blog in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I simply wanted to give you a quick heads up! Other than that, great website!

Building Contractors West London
12/15/2017 8:19:59 PM #

i seach the full album plz  Stop by my weblog ...  Building Contractors West London - http://Bit.ly/2zrVXTJ+

Add comment