I've created a new command in my ViewModel of the scheduleview that works properly in a context menu associated with the scheduleview, however when I try and place this command on a button outside the scheduleview control it doesn't trigger that an appointment has been selected or not.
I can make the CanExecute always return true and then it will fire the event properly when clicked, however I need it to disable/enable when an appointment is selected and it has specific values set in the appointment. The edit button triggers the selection changed ok when outside the schedule view. How do I get this same functionality for my command/button?
public
DelegateCommand StartVisitCommand {
get
{
return
this
.startVisitCommand; }
set
{
this
.startVisitCommand = value; } }
<
telerik:RadButton
Content
=
"Start Visit"
Grid.Column
=
"4"
Command
=
"{Binding DataContext.StartVisitCommand, ElementName=scheduleview}"
CommandTarget
=
"{Binding ElementName=scheduleview}"
CommandParameter
=
"{Binding SelectedAppointments, ElementName=scheduleview}"
DockPanel.Dock
=
"Right"
/>
private
void
StartVisitCommandExecuted(
object
parameter)
{
IEnumerable appointments = parameter
as
IEnumerable;
SqlAppointment appt = appointments.OfType<SqlAppointment>().Where(x => x.TimeMarkerID == 3).FirstOrDefault();
SchedulingInterface.CreateDocumentationByAppt(appt);
}
private
static
bool
CanExecuteStartVisitCommand(
object
parameter)
{
IEnumerable appointments = parameter
as
IEnumerable;
if
(appointments !=
null
)
{
SqlAppointment appt = appointments.OfType<SqlAppointment>().Where(x => x.TimeMarkerID == 3).FirstOrDefault();
if
(appt !=
null
)
return
appt.CurrentTimeMarkerId ==
"3"
;
}
return
false
;
}