-1

I'm using Visual Studio 2012 and I'm developing a project with C# and WPF. In my application I need to have a simple settings window, as you can see in every Windows application. So, I create a new page with a treeview on the left and a frame on the center. When I click on a treeview item, the content of the frame changes. If I select a checkbox present in page1, then I select second treeview item, when I return back to first the checkbox loses his selection. I need that values are maintained and, if I click OK button, values are stored in a xml file (I just know how to write to an XML file). Do you know any samples about this kind of development?

Thanks for your help

Francesco

4

1 回答 1

1

You can create instances of each page at setting page creation time

Page1 page1 = new Page1();

and then switch between them like this:

internal static void LoadPage(string pageName)
{
    string currentPage = "";
    if (Main_Content.Content != null)
    {
        var page = Main_Content.Content as Page;
        if (page != null)
            currentPage = page.Name ?? "";
    }

    if (currentPage != pageName)
    {
        switch (pageName)
        {
            case "page1":                   
                Main_Content.Content = page1;
                break;      
        }
    }
}
于 2013-06-10T10:10:31.680 回答