Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Visibility = IsCollapsed skip the data-binding part?

If I set a StackPanel or what ever bound area I have as 'Collapsed', does the data load?
Will it trigger its Loaded event?

like image 556
Shimmy Weitzhandler Avatar asked Jan 22 '10 05:01

Shimmy Weitzhandler


1 Answers

Yes:

  • Your data bindings will be evaluated,
  • Your Initialized events will fire, and
  • Your Loaded events will fire

But in the section of the visual tree under the Visibility="Collapsed" element:

  • Your controls will not be measured or arranged
  • Your controls' Templates will not be applied

So the bottom line is, if you want to avoid loading data for invisible sections of your UI, don't load your data and set your DataContext until after the control is first measured. Also consider putting any complexity inside a template.

like image 50
Ray Burns Avatar answered Oct 16 '22 19:10

Ray Burns