Click here to Skip to main content
13,596,541 members
Rate this:
Please Sign up or sign in to vote.
See more:
Dear All,

Is there any way to change the content of the current page to the content of another page using code behind.
Please note that the current page is being called from a frame in the mainwindow.

Thanks in Advance
Posted 26-Dec-12 2:10am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi , you can achive by next mean:
string xaml =
    "<grid margin="10" hold=" />        " xmlns="" xmlns:x="" xmlns:sdk="">" + 
        "<grid.columndefinitions>" +
            "<columndefinition width="100" />" +
            "<columndefinition width="*" />" +
        "</grid.columndefinitions>" +
        "<grid.rowdefinitions>" +
            "<rowdefinition height="Auto" />" +
            "<rowdefinition height="Auto" />" +
            "<rowdefinition height="Auto" />" +
            "<rowdefinition height="*" />" +
        "</grid.rowdefinitions>" +
        "<textblock text="First Name" height="19" margin="0,7,31,4" />" +
        "<textbox x:name="FirstName" margin="3" grid.row="0" grid.column="1" />" +
        "<textblock text="Last Name" margin="0,7,6,3" grid.row="1" height="20" />" +
        "<textbox x:name="LastName" margin="3" grid.row="1" grid.column="1" />" +
        "<textblock text="Date of Birth" grid.row="2" margin="0,9,0,0" height="21" />" +
        "<sdk:datepicker x:name="DateOfBirth" margin="3" grid.row="2" grid.column="1" />" +
        "<button x:name="SubmitChanges" grid.row="3" grid.column="3" hold=" />            " horizontalalignment="Right" verticalalignment="Top" margin="3" width="80" height="25" content="Save" />" +
    UIElement tree = (UIElement)XamlReader.Load(xaml);

To read a XAML of existing page you might perform next operation:
StreamResourceInfo sri = Application.GetResourceStream
    (new Uri("SilverlightTestApp;component/Page.xaml", UriKind.Relative));
StreamReader reader = new StreamReader(sri.Stream);
Output.Text = reader.ReadToEnd();

And the last thing that still remains for you is to collate this two pieces of code and make one proper =)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web02 | 2.8.180621.3 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100