Reputation: 7237
I have a custom Calendar control that is showing appointments in a chosen period of time.
I would like to add the ability to create/edit appointments. Appointment edit dialog (fields, save button, cancel button) should open when I click on a day.
Who should be responsible for opening the edit dialog?
Should the control be responsible for opening the dialog and have just SaveCommand
and EditedAppointment
property.
Or should it just expose commands/events for the user like BeginEditCommand/DayClick event
and the user of my control would have to implement the dialog by herself (instead of just implementing Save command)? I think DataGrid works that way
Both solutions will work but which is better?
It's my first custom control in WPF so excuse me for a noob question.
Upvotes: 0
Views: 58
Reputation: 21261
It's impossible to say for definite without understanding where your control fits in the grand scheme of things, but to me editing and adding appointments sound like a part of the application rather than a simple control.
Controls tend to be good at one distinct thing, and reusable in many different scenarios, so need to be flexible. What if the app wanted to skin the appointment edit screen differently? Or display it in a completely different window? Or allow editing of multiple appointments at once?
You could always create another control for editing appointments that they are free to use if you want to make it easy for consumers, and they can plumb it in as they see fit. To be honest though, these things feel like they should be implemented as proper MVVM in the app rather than as custom controls.
Upvotes: 1