Click here to Skip to main content
12,455,517 members (57,843 online)
Click here to Skip to main content

Tagged as

Stats

99.7K views
2.8K downloads
60 bookmarked
Posted

Save and Restore WPF Window Size, Position, and/or State

, 3 Aug 2012 CPOL
A quick example of how you can save the window size, position, and/or state, and restore your form to that size, position, and state the next time the app is launched.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="SaveWindowPosition.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <userSettings>
        <SaveWindowPosition.Properties.Settings>
            <setting name="WindowTop" serializeAs="String">
                <value>100</value>
            </setting>
            <setting name="WindowLeft" serializeAs="String">
                <value>100</value>
            </setting>
            <setting name="WindowHeight" serializeAs="String">
                <value>300</value>
            </setting>
            <setting name="WindowWidth" serializeAs="String">
                <value>300</value>
            </setting>
            <setting name="WindowState" serializeAs="String">
                <value>Normal</value>
            </setting>
        </SaveWindowPosition.Properties.Settings>
    </userSettings>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jeremy Hutchinson
Software Developer
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 3 Aug 2012
Article Copyright 2010 by Jeremy Hutchinson
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid