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.
EditTaskshould 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 tiraboolenables / disables editing options depending on the mode. Often it can even be added to form elements - Sergey