locked
Using CLR Classes in Interactive Designer (pkiddie) - 3/17/2006 9:50 AM PST RRS feed

  • Question

  • By: pkiddie

    Hi,
    
    I've built a Machine class in the following manner:
    
    internal class Machine
        {
            public Machine()
            {
            }
    
            private string name;
    
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            
            private ImageSource machinePhoto;
            
            public ImageSource MachinePhoto
            {
            get { return machinePhoto; }
            set { machinePhoto = value; }
            }
        }
    
    I would like to reference this in my XAML. I've been following a guide from 
    PDC'05 which states to do so you must:
    
    a) make a mapping to the CLR class: 
    <?Mapping XmlNamespace="myapp" ClrNamespace="InductionAssistant" ?>
    
    b) Give it a namespace reference in the XAML file:
    xmlns:my="myapp"
    
    And then I guess I should be able to use the class by:
    <DataTemplate DataType="{x:Type my:Machine}">
    
    I've followed all those above steps but the XAML parser within Interactive 
    Designer keeps giving me an error about the 'Machine' type not being found. 
    Consequently, I get a BamlParseException when I run the WPF app. I believe 
    that this is from a much earlier CTP than the one i've got currently on my PC 
    (Feb/March 06), so has anything changed significantly or am I missing 
    something?
    
    Any help would be greatly appreciated!
    Many Thanks,
    Paul
    
     
    
    Monday, February 18, 2008 10:09 PM

Answers

  • By: Unni Ravindranathan (MS)

    The namespace mapping statement syntax has changed since. To achieve similar
    results, use the following:

    <Grid....
    xmlns:myapp="clr-namespace:InductionAssistant"
    >
    ....
    </Grid>

    Hope this helps. If not, please send me the project at unnir at microsoft
    dot com.

    Thanks,
    -Unni

    --
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "pkiddie" <pkiddie@discussions.microsoft.com> wrote in message
    news:B1A1C284-39E4-4B83-824E-0D5F4F73ED6D@microsoft.com...
    > Hi,
    >
    > I've built a Machine class in the following manner:
    >
    > internal class Machine
    > {
    > public Machine()
    > {
    > }
    >
    > private string name;
    >
    > public string Name
    > {
    > get { return name; }
    > set { name = value; }
    > }
    >
    > private ImageSource machinePhoto;
    >
    > public ImageSource MachinePhoto
    > {
    > get { return machinePhoto; }
    > set { machinePhoto = value; }
    > }
    > }
    >
    > I would like to reference this in my XAML. I've been following a guide
    > from
    > PDC'05 which states to do so you must:
    >
    > a) make a mapping to the CLR class:
    > <?Mapping XmlNamespace="myapp" ClrNamespace="InductionAssistant" ?>
    >
    > b) Give it a namespace reference in the XAML file:
    > xmlns:my="myapp"
    >
    > And then I guess I should be able to use the class by:
    > <DataTemplate DataType="{x:Type my:Machine}">
    >
    > I've followed all those above steps but the XAML parser within Interactive
    > Designer keeps giving me an error about the 'Machine' type not being
    > found.
    > Consequently, I get a BamlParseException when I run the WPF app. I believe
    > that this is from a much earlier CTP than the one i've got currently on my
    > PC
    > (Feb/March 06), so has anything changed significantly or am I missing
    > something?
    >
    > Any help would be greatly appreciated!
    > Many Thanks,
    > Paul
    >
    >
    >
    Tuesday, February 19, 2008 12:50 AM