Ask a questionAsk a question
 

AnswerPageFunction and resources

  • Thursday, May 15, 2008 9:40 AMy-spring Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    given:
    Code Snippet

    <PageFunction

      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

      xmlns:sys="clr-namespace:System;assembly=mscorlib"

      x:Class="Test.NewDeviceWizard"

      x:TypeArguments="sys:String">



    How do I add a resources section?

    <PageFunction.Resources></PageFunction.Resources>
    results in 2 errors:
    • The attachable property 'Resources' was not found in type 'PageFunction'.
    • The tag 'PageFunction.Resources' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.
    Intellisense/Code-completion (or however it is being called in VS2008 xaml editor) suggests:

    <PageFunction`1.
    But this invalidates the entire xaml file.

Answers

  • Monday, May 19, 2008 10:39 AMy-spring Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I found out that you are't forced to reuse the root elements name:
      <TreeView><TreeView.Resources><!-- ...


    instead you can use a baseclass's name or just the class name where the property was introduced:
      <TreeView><FrameworkElement.Resources><!-- ...
    or
      <PageFunction [..]><Page.Resources><!-- ...
    or
      <TreeView><ItemsControl.ItemTemplate><!-- ...

    IntelliSense-mouse-hovering always shows it this way.

All Replies

  • Monday, May 19, 2008 4:33 AMMarco Zhou Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I think this is an issue with the XAML compiler, the XAML compiler should work correctly when parsing the Resources belonging to generic root element, I would greatly appreciate it if you could feedback this issue at the following connect site alongside with the repro code you pasted above:

    https://connect.microsoft.com/feedback/default.aspx?SiteID=212&wa=wsignin1.0


    To workaround this issue, you might need to add the resources at code behind instead.

    Hope this helps
  • Monday, May 19, 2008 10:39 AMy-spring Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    I found out that you are't forced to reuse the root elements name:
      <TreeView><TreeView.Resources><!-- ...


    instead you can use a baseclass's name or just the class name where the property was introduced:
      <TreeView><FrameworkElement.Resources><!-- ...
    or
      <PageFunction [..]><Page.Resources><!-- ...
    or
      <TreeView><ItemsControl.ItemTemplate><!-- ...

    IntelliSense-mouse-hovering always shows it this way.
  • Tuesday, May 20, 2008 2:23 AMMarco Zhou Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    That's a nice workaround indeed, but I think that usage pattern is actually an implementation detail, and is sometimes confusing, I still suggest feedbacking this issue at connect

    Thanks