How to redirect on XAML file to anotherXAML file in same project RRS feed

  • Question

  • Hi,

    How can i call one xaml file from another xaml file in same project .

    Example :

        Suppose in  my First.xaml  file have one button  .onclick of this button i want to show second.xaml file  how i can achive this by using javascript as a code behind.




    Tuesday, February 27, 2007 8:42 AM

All replies

  • Hi,

    Try this ...


    var control = document.getElementById("wpfeReport"); // Where wpfeReport is your agHost

    control.Source = 'App_Xaml/Report2.xaml'; // Where App_Xaml/Report2.xaml is your new xaml file




    Tuesday, February 27, 2007 6:59 PM
  • Thanks for reply.

    I checked  it and its working . 


    Hey  Thiago Henrique da Silva    but i want to show  xaml file  within canvas .

    Example :

       Suppose in my canvas first.xaml is loaded initially  and after a click of a button i want to change the canvas content to second.xaml .

        How can i do this ?


    Wednesday, February 28, 2007 5:17 AM
  • Is the outer canvas of first.xaml so important that you cannot simply replace first.xaml with second.xaml? Or are you trying to replace an "inner" canvas with the contents of second.xaml

    If so, you can dump the children of the first canvas with Canvas.children.clear(), and then use Control.createfromxaml to create the new content and add it to the place you just cleared.

    There's a catch though, you can't just reset the control's source to second.xaml or you replace all the content. Yet you still need to get the second.xaml from the server. You'd likely have to use xmlhttp to get the second.xaml "out of band" from the controls' getting mechanism. Then you would have to get a string from the xmlhttp stream to pass to the Control.Createfromxaml method. Do-able, but I haven't done it before

    Maybe you should supply some pseudocode that describes in more detail what you are trying to do.


    Wednesday, February 28, 2007 8:28 AM
  • Thanks for reply.

           As u said to clear canvas i know it ,but i want to change canvas content from one xaml file to another xaml file because xaml file contents are too heavy to create dynamically .

           If u know how to load a xaml file in canvas dynamically please send me it with simple code .






    Wednesday, February 28, 2007 10:11 AM
  • Hi Dinesh,

    Why you dont get the "SourceString" from your canvas do some parsing in this string removing old content and putting your new content ?

    A sample how use the SourceString:

    // Retrieve a reference to the WPF/E control.
    var control = document.getElementById("WpfeControl");

    // Define the XAML content.
    control.SourceString = '<TextBlock xmlns="http://schemas.microsoft.com/client/2007" Text="Hello, world" />';

    // Reload the WPF/E control to force the property change to take effect.


    Wednesday, February 28, 2007 11:42 AM
  • Thanks for reply.

     I think your not getting my problem 1

        Here i explain  my problem.


    Suppose i have two canvas  their names like  =  canvas_firstcanvas_second

            In my  canvas_first  contiain two buttons  their  names  are like First_btn and second_btn.

            when i click on first_btn then the first.xaml file is loaded in canvas_second and when i click on

    second_btn  then second.xaml is loaded in canvas_second . 




    Wednesday, February 28, 2007 1:17 PM
  • hi Dinesh

    When u click in First_btn:


    var control = document.getElementById("canvas_second");

    control.Source = 'first.xaml';



    And when u click in second_btn:


    var control = document.getElementById("canvas_second");

    control.Source = 'second.xaml';



    Just how i have said in first reply.





    Wednesday, February 28, 2007 1:26 PM
  • Hi Thiago Henrique da Silva ,

      I tried it and i got error like "Unspecified error "  at line  control.Source = 'first.xaml';

     I am waiting for reply.

     if possible please send your  email id so that we can chat .

     My gmail id is : dinchaudhari@gmail.com



    Wednesday, February 28, 2007 1:54 PM