Thomas Wingfield
Thomas Wingfield

Reputation: 95

Why I have a (error does not implement interface member) silverlight

PagesCollection.ViewModel.PagePictureCommands.cs

namespace PagesCollection.ViewModel
{
    public partial class PagePicturesViewModel : IPropertieCommands
    {
        private ICommand deleteAlbum;
        public ICommand _CreateAlbum
        {
            get
            {
                if (createAlbum == null)
                    createAlbum = new Model.DelegateCommand(CreateAlbum, CanAdd);
                return createAlbum;
            }
        }
    }
}

PagesCollection.ViewModel.PagePicturesViewModel.cs

namespace PagesCollection.ViewModel
{
    public partial class PagePicturesViewModel : IPictureMethods
    {
        public void CreateAlbum(object param)
        {...}
    }
}

I have one 2 interfaces and one class which divided on 2.Each one half of class has implemented some of those interfaces.But I have a very strange error. ('PagesCollection.ViewModel.PagePicturesViewModel' does not implement interface member 'PagesCollection.Model.IPropertieCommands._CreateAlbum.set') Can u help me please?

Upvotes: 0

Views: 7808

Answers (3)

Suresh Kaushik
Suresh Kaushik

Reputation: 77

public interface IPropertieCommands
{
   ICommand _CreateAlbum { get;}
}

If you don't want this property to have a setter (readonly), you can have your interface code like above.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1503090

It looks like your IPropertieCommands interface requires that the _CreateAlbum property has a setter - but you've only implemented a getter.

Upvotes: 1

Jamiec
Jamiec

Reputation: 136164

What is it you don't understand, because the error message seems pretty descriptive:

PagesCollection.ViewModel.PagePicturesViewModel' does not implement interface member 'PagesCollection.Model.IPropertieCommands._CreateAlbum.set

I suspect that the interface looks like:

public interface IPropertieCommands
{
   ICommand _CreateAlbum { get; set; }
}

Which defines that you must have a setter on that property!

So just add a setter in your implementation:

public ICommand _CreateAlbum
{
    get
    {
        if (createAlbum == null)
            createAlbum = new Model.DelegateCommand(CreateAlbum, CanAdd);
        return createAlbum;
    }
    set
    {
        createdAlbum = value; // or something else sensible!
    }
}

Upvotes: 3

Related Questions