How does the Pages.Xaml file work in a silverlight app? RRS feed

  • Question

  • How does the Pages.Xaml file work in a silverlight app?
      What are the ways to view XAML code graphically?

      I have been handed a SilverLight application in Visual Studio 2008.

      When I was working on a WCF application in Visual Studio 2010, I noticed I could view XAML code graphically.  In other words, I could actually see the image of what I was working on.  Can you do the same thing in Visual Studio 2008?  I am guessing that this is what Expression Blend is for.

      In Expression Blend, I get the following error when I try to open App.xaml:

       App.xaml cannot be edited in design view.
       To edit resources, select from the Resources panel.

      But there is another xaml page.  Is the file "page.xaml" one that is common in most silverlight projects?  When I open this file by clicking on it in Expression Blend a tabbed interface oppens up in Expression bland that looks somewhat like how the flash developers user interface looks like.  This opens a flood of questions for me.  Is it really just one xml file or a combination?  I looked at the xml structure of this XAML file code in Visual Studio and I see that it is arragned such in such a way that I can see how it could be  used to swap out page contents s in groups.  Is this common?  How is the code designed to make this happen?

      I noticed that a lot of introductionaly tutorials for Expression Blend online were in the form of videos.  I cannot watch these right now because I do not have a set of headphones.  Is there some other way to learn this stuff?

    Web Master and Programmer
    Friday, June 25, 2010 11:51 PM

All replies

  • Hi Bill,

    App.xaml cannot be viewed graphically because it is a resource file, no visual element. You can click on the XAML buttom on that panel top right corner to view it in XML text.

    if the computer speaker didn't work, you may read the "Tutorials and Whitepapers" section first:




    Thanks, Harry Huang [MSFT]
    • Proposed as answer by Harry.MSFT Saturday, June 26, 2010 2:42 AM
    Saturday, June 26, 2010 2:40 AM
  • Hi Harry,

    I have a LayoutGroup question.

    I have been handed a SilverLight application to investigate and work on.

    I have watched a few training videos and I am starting to get a feel for how Silverlight projects are put together.  I found this workflow diagram to be helpful:

    Does every Silverlight Project contain a LayoutGroup?
    Does every Silverlight Project require to contain a App.xaml and App.xaml.cs file?
    Does every Silverlight Project require to contain a Page.xaml and Page.xaml.cs file?

    The project I have been handed has what seems to be multiple pages that make up the page file.  And the way that Expression Blend organizes them has something to do with these little eye symbols.  Is there a tutorial that explains all this somewhere and explains how silverlight switches between these different views at run time?



    Web Master and Programmer
    Monday, June 28, 2010 3:46 AM
  • By convention every SL app will have an app.xaml and app.xaml.cs file that are the application wide resources, and the application entry point.

    The application will start up and assign something as the rootvisual. That something generally is a usercontrol, which will often by convention have a container control (grid, canvas, etc...) named LayoutRoot. It doesn't have to be named that, but most templates have it named that. In Silverlight this is set up in app.xaml.cs in the application constructor.

    Often applications may want to use a page based model of navigation between pages, to do this there is a navigation framework built in. In this case your main usercontrol might have a frame element, which can load different pages.  Search for silverlight navigation framework for more info on that.


    Monday, June 28, 2010 2:04 PM