<?Mapping?> fails after upgrade to beta 2

To use a custom panel Foo.Bar.CustomPanel in XAML, I do the following:

< Mapping XmlNamespace="foo/bar" ClrNamespace="Foo.Bar" >
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:foobar="foo/bar"
...
<foobar:CustomPanel .../>

After updating to WinFX beta 2, this no longer works. I get the following error:
Error 5 'CustomPanel' tag does not exist in XML namespace 'foo/bar'.

Does anyone know how to use a custom class in XAML in beta 2 I'm probably not looking in the right places, but I can't find the answer. Thank you.


Answer this question

<?Mapping?> fails after upgrade to beta 2

  • Namfon

    Hi there,

    I have tried the following with no luck:

    <Window x:Class="WorkBench.MainShell"

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

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

    xmlns:cmt="clr-namespace:Cmt.UI.ADR2000;assembly:CustomView.dll"

    Title="WorkBench" Height="325" Width="386"

    >

    <DockPanel>

    <cmt:PatientView/>

    </DockPanel>

    </Window>

    Where PatientView is derives from ContentControl, declared inside the CustomView.dll (I also tried to omit the ".dll"). Of course the Cmt.UI.ADR2000 is the namespace.

    What did I do wrong



  • sun21170

    It turns out my installation was somewhat borked, and that's why I couldn't find the answer in the documentation. Once I got the docs installed correctly, I found the answer quickly. In case anyone else needs the answer:

    Instead of < Mapping > directives, you now define the CLR namespace of the XML namespace in the XML namespace declaration:
    <... xmlns:foobar="clr-namespace:Foo.Bar[;assembly=XXX]" .../>
    Don't include the '.dll' extension in the assembly name.

  • John C MCSD

    Thanks, it works. I had also added a reference to this assembly, and omitted the ".dll".

    Now I have the following warning:

    Warning 1 The element 'Grid' in namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation' has invalid child element 'PatientView' in namespace 'clr-namespace:Cmt.UI.ADR2000;assembly=CustomView'. List of possible elements expected: 'Grid.ShowGridLines, Grid.ColumnDefinitions, Grid.RowDefinitions, Grid.Background, Grid.IsItemsHost, Grid.Style, Grid.OverridesDefaultStyle, Grid.Triggers, Grid.Resources, Grid.DataContext, Grid.Language, Grid.Tag, Grid.InputScope, Grid.LayoutTransform, Grid.Width, Grid.MinWidth, Grid.MaxWidth, Grid.Height, Grid.MinHeight, Grid.MaxHeight, Grid.Margin, Grid.FocusVisualStyle, Grid.Cursor, Grid.ForceCursor, Grid.Focusable, Grid.ToolTip, Grid.ContextMenu, Grid.InputBindings, Grid.CommandBindings, Grid.AllowDrop, Grid.RenderSize, Grid.RenderTransform, Grid.RenderTransformOrigin, Grid.Opacity, Grid.OpacityMask, Grid.BitmapEffect, Grid.BitmapEffectInput, Grid.ClipToBounds, Grid.Clip, Grid.SnapsToDevicePixels, Grid.IsEnabled, Grid.IsHitTestVisible, sgUIElement, sgFrameworkElement, sgShape, Ellipse, Line, Path, Polygon, Polyline, Rectangle, sgPanel, Canvas, DockPanel, Grid, TabPanel, ToolBarOverflowPanel, sgStackPanel, ToolBarPanel, UniformGrid, sgVirtualizingPanel, VirtualizingStackPanel, WrapPanel, sgControl, sgC.... D:\Documents and Settings\Tomer\My Documents\Visual Studio 2005\Projects\CMT\WorkBench\WorkBench\MainShell.xaml 9 4 WorkBench

    Here is the XAML of my Custom Control:

    <ContentControl x:Class="Cmt.UI.ADR2000.PatientView"

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

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

    </ContentControl>

    Here is the .cs of my Custom Control:

    public partial class PatientView : ContentControl

    {

    public PatientView()

    {

    InitializeComponent();

    }

    }

    What did I do wrong

    Thanks.



  • alimoaz

    Hey awhite,

    Could you post a more specific example of the usage of mapping, both in the class declaration within the clr-namespace and in the XML

    Thank you..


  • Su4v3

    > What did I do wrong

    Actually it was my mistake; my post had an error. I've now corrected it: notice that you use an '=' instead of a ':' before the assembly name. I haven't tried this as I haven't needed to link to an assembly yet, but that's what the docs say. Good luck.

  • <?Mapping?> fails after upgrade to beta 2