Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get FrameworkElement properties before its unloading
    text
    copied!<p>It is need to realize UI settings system - loading/saving some properites of UI elements (which can be modified by user in runtime) from/into persistent storage. For example:</p> <ul> <li>DevExpress grid control - columns width's, visibility, summary area and so on (this control has set of methods pairs like RestoreLayoutFrom/SaveLayoutTo, but SaveLayoutToStream(Xml) doesnt work in grid.Unloaded handler - when grid is disconnected from PresentationSource)</li> <li>grid rows/columns, which widths/heights can be adjusted by user via GridSplitter</li> <li>sizeable popup controls</li> </ul> <p>It is easy to set up controls properties from settings storage after controls loading/initializing/etc, but how catch the moment before controls unloading (when they still remains in visual tree) in order to retrieve their settings for saving?</p> <h2>Short description</h2> <p>I intend to create singleton - UISettingsManager, which inside has a Dictionary with pairs of [element Uid, element settings data]. In visual container (Window, UserControl) this manager can be used in a way like this:</p> <pre><code>public partial class PageHeader : UserControl { public PageHeader() { InitializeComponent(); UISettingsManager.RestoreSettings(myGridControl); UISettingsManager.RestoreSettings(myPopup); } } </code></pre> <p>myGridControl &amp; myPopup has unique Uid's (in application scope), so UISettingsManager can retrieve their settings from inner dictionary &amp; apply it to the controls; of course UISettingsManager knows, how to work with some different types of controls. </p> <p>But when it is the right moment to store settings of controls, which container is Window or UserControl?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload