locked
PageFunction and x:TypeArguments RRS feed

  • Question

  • Hi

    I have recently started working with c# and wpf. Im trying to create a structured navigation app as described in the sdk documentation. For each PageFunction class in its corresponding xaml I have to assign x:TypeArguments a type in the same namespace. Is there a reason for this?

    Thanks for any help

    Regards

    Helen 

     

    Tuesday, February 7, 2006 11:48 AM

Answers

  • We're reviewing the grammar necessary inside of the x:TypeArguments attribute.

    The current grammar relies on the generated "using" statements in the generated code file (.g.cs/.g.vb).

    The using statements in the .g.cs file are currently determined by the set of xmlns declarations you have in your .xaml file. 

    If you want to use a custom class Customer as a TypeArgument in the current build, do the following:

    1) add a mapping PI statement
    <?Mapping XmlNamespace="local" ClrNamespace="MyProject.BusinessObjects" ?>

    2) add a xmlns declaration
    <PageFunction xmlns="..." xmlns:my="local" ... >
    (this will create a "using MyProject.BusinessObjects;" in the .g.cs file)

    3) refer to your type in x:TypeArguments
    <PageFunction ... x:TypeArguments="Customer"
    (today, that string is pasted in to the .g.cs file as:
    class MyPageFunction : PageFunction<Customer>

    ----

    That will work today, but has a few problems.
    A) you can't resolve any ambiguity if you have a type that is declared in 2 of your clr namespaces that have usings.
    B) it isn't like all other type references in xaml ("<foo:Button>")
    C) ...

    ----

    Was I right in interpreting what you wanted to do...use your own custom class?

    Did you expect to refer to it as x:TypeArguments="my:Customer"?

    Thanks, Rob Relyea
    PM, WPF Team

    Tuesday, February 7, 2006 12:29 PM

All replies

  • We're reviewing the grammar necessary inside of the x:TypeArguments attribute.

    The current grammar relies on the generated "using" statements in the generated code file (.g.cs/.g.vb).

    The using statements in the .g.cs file are currently determined by the set of xmlns declarations you have in your .xaml file. 

    If you want to use a custom class Customer as a TypeArgument in the current build, do the following:

    1) add a mapping PI statement
    <?Mapping XmlNamespace="local" ClrNamespace="MyProject.BusinessObjects" ?>

    2) add a xmlns declaration
    <PageFunction xmlns="..." xmlns:my="local" ... >
    (this will create a "using MyProject.BusinessObjects;" in the .g.cs file)

    3) refer to your type in x:TypeArguments
    <PageFunction ... x:TypeArguments="Customer"
    (today, that string is pasted in to the .g.cs file as:
    class MyPageFunction : PageFunction<Customer>

    ----

    That will work today, but has a few problems.
    A) you can't resolve any ambiguity if you have a type that is declared in 2 of your clr namespaces that have usings.
    B) it isn't like all other type references in xaml ("<foo:Button>")
    C) ...

    ----

    Was I right in interpreting what you wanted to do...use your own custom class?

    Did you expect to refer to it as x:TypeArguments="my:Customer"?

    Thanks, Rob Relyea
    PM, WPF Team

    Tuesday, February 7, 2006 12:29 PM
  • sort of - I just want to set the generic return type for a PageFunction to be a custom class defined in a namespace that isnt the same as the namespace the PageFunction subtype is defined in. And the problem seemed to be assigning x:TypeArguments in the xaml.

    I have done as you suggested above but now Im getting compile errors from the .g.cs files where it seems to be looking for types in the wrong namespace.

    Will post some code and error messages tomorrow to better explain.

    Regards

    Helen

     

     

    Tuesday, February 7, 2006 5:00 PM