locked
How to Add a Page.Resources block with Blend

    Question

  • The following code:

    <Page.Resources>
            <local:SampleModel x:Key="SampleModelDataSource"></local:SampleModel>
    </Page.Resources>

    was hand-typed into my Xaml file to allow my model data to bind to the page. (Which works, thank you.)

    This project is a C++ Metro project.

    Question:  Is there a way in Blend to add a resource without hand-typing it?

     

    Jim Tomasko


    • Edited by James Tomasko Friday, June 8, 2012 6:41 PM adding info
    Friday, June 8, 2012 6:39 PM

Answers

  • Hi Navit,

    Sorry, that does not work for the Page control.  If you open a blank Blend project (as I am starting with), the "Convert to New Resource..." option is disabled.

    But.... after trying that, I did finally solve my question, and I like the solution...

    On a new page, you can set the DataContext for the page by pressing the "New" button next to the little square... funny.... I've used Blend forever, and I've never found that button to be useful to me before.

    It actually pops up a dialog that shows (what appears to me as) all the classes in my project that have been "groomed" for Xaml usage.... very very nice.


    Jim Tomasko

    • Marked as answer by James Tomasko Saturday, June 9, 2012 10:18 PM
    Saturday, June 9, 2012 10:18 PM

All replies

  • In Blend you can set the DataContext property on the control using the Property Inspector and then "Convert it to new Resource".

    HTH.

    -Navit Saxena

    Saturday, June 9, 2012 6:37 PM
  • Hi Navit,

    Sorry, that does not work for the Page control.  If you open a blank Blend project (as I am starting with), the "Convert to New Resource..." option is disabled.

    But.... after trying that, I did finally solve my question, and I like the solution...

    On a new page, you can set the DataContext for the page by pressing the "New" button next to the little square... funny.... I've used Blend forever, and I've never found that button to be useful to me before.

    It actually pops up a dialog that shows (what appears to me as) all the classes in my project that have been "groomed" for Xaml usage.... very very nice.


    Jim Tomasko

    • Marked as answer by James Tomasko Saturday, June 9, 2012 10:18 PM
    Saturday, June 9, 2012 10:18 PM