views:

21

answers:

1

Attempt to make a stub data for custom Silverlight 4 control failed.

Here is XAML code:

<UserControl x:Class="VfmElitaSilverlightClientView.Pages.FieldItem"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="32" d:DesignWidth="32"
    d:DataContext="{d:DesignInstance
        local:VfmElitaSilverlightClientView.ViewModelStub.SquadPlayerViewModelStub,
        IsDesignTimeCreatable=True}"
        >

<Canvas Name="canvas" >
    <Ellipse Fill="Yellow" Canvas.Top="8" Canvas.Left="8" Height="16" Width="16">
    </Ellipse>        
</Canvas>

Specified class was implemented too:

namespace VfmElitaSilverlightClientView.ViewModelStub
{
    public class SquadPlayerViewModelStub
    {    
        public int TeamNumber
        {
            get { return 12; }
        }
    }
}

Project is compiled successfully, but on attempt to load control in designed following error is occured:

Error 1 Type 'local:VfmElitaSilverlightClientView.ViewModelStub.SquadPlayerViewModelStub' was not found.

Guess, something is wrong with syntax, but can't find what exactly.

Please let me know how to get control loadable in design time with 'custom' (stub) data.

Thanks

A: 

We took your layout/code and got it working by simply adding the "local" XML namespace to the xmlns declarations:

xmlns:local="clr-namespace:VfmElitaSilverlightClientView.ViewModelStu"...

and changing the datacontext to d:DataContext="{d:DesignInstance local:SquadPlayerViewModelStub, IsDesignTimeCreatable=True}

Enough already
heh... it's strange...
Budda