Hi,
I have a ScheduleView where I want it to initially be readonly. But then open for edit by clicking a toggle button.
Right now I have added the ReadOnlyBehaviour... and I can see how I can remove it.. but adding it back when clicking out of Edit mode is not so clear.
I had an idea to add a bindable property to my readonlybehaviour like this:
public class ScheduleViewReadOnlyBehaviour : ReadOnlyBehavior
{
private bool _isReadOnly;
public static readonly DependencyProperty ReadOnlyProperty =
DependencyProperty.Register(nameof(ReadOnly), typeof(bool), typeof(RadScheduleView),
new PropertyMetadata(true, ReadOnlyPropertyChanged));
private static void ReadOnlyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((ScheduleViewReadOnlyBehaviour)((RadScheduleView)d).ReadOnlyBehavior).ReadOnlyPropertyChanged((bool)e.NewValue);
}
private void ReadOnlyPropertyChanged(bool isReadOnly)
{
_isReadOnly = isReadOnly;
}
public bool ReadOnly
{
get { return (bool)GetValue(ReadOnlyProperty); }
set { SetValue(ReadOnlyProperty, value); }
}
public override bool CanSaveAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanEditAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanDragAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanResizeAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanDeleteAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return false;
}
public override bool CanEditSlot(IReadOnlySettings readOnlySettings, Slot slot)
{
return false;
}
}
But keep ending up with the GetValue and SetValue methods not found.. obviously missing a point here. Would be a nice clean way of solving this problem.
And yes, I am aware that I am currently not actually using the value being bound... I see that as the least of my issues.