There is a certain collection of interfaces

public interface ITask { string Name { get; set; } void CreateTask(); void EditTask(); void Run(); } 

There will be several classes of implementers, and they will be somewhat different, so much so that for editing you cannot make a generalized window - and for each you have to make a separate view. So far he has become a bit like this (for an example from one class):

 public void EditTask() { var w = new CreatePicturePostingTaskWindow(); w.DataContext = this; w.Show(); } 

I tried to send by messenger

 Messenger.Default.Send(new EditPicturePostingTask(ref t)); 

But still it turns out somewhat verbose and ugly.

Surely someone faced with a similar task, and decided it more sensibly, and will be able to give me a couple of tips.

PS Another side problem - using the same view both for adding a new element and for editing - you have to attach ugly crutches to select the mode of operation.

  • one
    Actually, it's actually getting worse. For each class in the application has its own view. EditTask should extract the desired view from this registry. So it is hardly unlikely to succeed, and more words are easy. What can there be crutches? Variable tira bool enables / disables editing options depending on the mode. Often it can even be added to form elements - Sergey
  • Well, the crutches in my architectural solution are just) Thank you. I just thought there was some kind of elegant solution, which I do not know about, but no, there are no wonderful lotions. - Sergey

0