In this case I have a Grid with a lot controls inside it , buttons, canvas, drawing, animations , all bound to view-models, I would like to disable all the dataTriggers, triggers , bindings inside its children and children of children, etc., when I set the visibility of the Grid to collapsed, so it is not wasting CPU cycles, (because a heavy animation is continuously running), and not crashing!
I'm using a behaviour: http://www.microsoft.com/design/toolbox/tutorials/pathlistbox/carousel.aspx
but it seems to have a bug that its making the app crash if the listbox is collapsed when using it, So I need to disable the databinding which activates the behaviour,
from what I found: Does Visibility = IsCollapsed skip the data-binding part?
So the only way to do it is putting everything inside a controltemplate:
<ContentControl Visibility="Collapsed">
<ContentControl.Template>
<Grid Name="Heavy Animation control">
<!--- animations, triggers, bindings , -->
</Grid>
</ContentControl.Template>
So in this way the Template wouldn't be applied and everything would be off until I switch the visibility.
So my question is: is this the correct way to address this issue?
Yes. Since the ContentControl is collapsed, the template will not be applied until you change the visibility to visible.
However, I would be interested in knowing how your grid is set up and whether you could break it down a bit more so that the buttons, canvas, drawing, animations, etc. are only initialized as they are needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With