Use an External ResourceDictionary in a WindowsPhone 7 app

前端 未结 3 2068
温柔的废话
温柔的废话 2020-12-30 09:15

I am trying to create an ResourceFile Called DataTemplate.xaml in an external dll and use that in a WP7 page. When I do the following in the header of my Page I get an erro

3条回答
  •  我在风中等你
    2020-12-30 10:11

    I've managed to get this to work using the following steps:

    1. Created a standard WP7 application using the "Windows Phone Application" application template called "WP7ExternalResourcesTest".
    2. Added a project to the same solution using the "Windows Phone Class Library" template called "WP7ExternalResourcesTestLibrary".
    3. Removed the default Class.cs file form the library project.
    4. Added a file called "External.xaml" using the "XML file" template and set the "Build Action" to "Page".
    5. Added the following XAML to the new XAML file:

      
          
      
      
    6. Built the library project, and then added a reference to it from the WP7ExternalResourcesTest project.
    7. In WP7ExternalResourcesTest, opened App.xaml and changed the Application.Resources section to the following:

      
          
              
                  
              
          
      
      
    8. In MainPage.xaml, added Foreground="{StaticResource ForegroundBrush}" to the TextBlock named "PageTitle".
    9. Ran the application in the emulator. The end result was that the TextBlock correctly displayed the words "page name" in red.

    Hope this helps.

提交回复
热议问题