can i except whole control from serialisation if i serialize my window ?
answered on 26 Nov 2012, 02:31 PM
When using the PersistenceFramework, you need to keep in mind that the framework saves the values of the UIProperties of all UIElements within the persisted control. This is why when you have a binding, the persistence manager will take the value defined by the binding and well save it as the value of the property in question. So if you have a binding for the Visibility property and the binding sets the Visibility to False, the persistence manager will save the Visibility property with value of False. This is why the approach for removing the bound properties out of the list with saved properties is a good approach.
And in case, you'd like to remove certain controls from the list pf persisted properties, you'll need to track the properties that define them. For example if you have a Window with one TextBlock in it, like so:
Basically you can define a SerializationOptions collection for each control in your Window. You only need to have in mind that you basically persist the properties of the main control (for example the Window), but if its Content/Items/Header/Children define other controls, in order to not persist them, you have to exclude the Content/Items/Header/Children property from the parent control.