Hi
Is there a way I can customize the time slot panel in XAMSchedule dayview.
1) What I want to do is to Run the time slot panel from say 6am Sunday to 5am Monday (i.e. I Still have 24hrs a day but my day Starts from 6am today and ends at 5am tomorrow). I should be able to still call it Sunday.
2) If 1 is possible can I also change the display time as start from 6 to 30 hr. clock(Just the display of time) (i.e. so instead of displaying 1,2,3 …..23 can I display 6,7,8…….28, 29,30
If the above 1 and 2 is not possible
1) Then can i just change the timeslot to display time in 6 to 30 hr. clock style.
2) And disable primary time zone and just display the secondary time zone.
I have attached the screen shots to explain waht i ment.
Regards
Saurabh
If you want your day to be considered as starting at 6am and ending at 6am of the following day (instead of 12am to 12am) then you can set the XamScheduleDataManager->Settings->LogicalDayOffset to 6 hours. This will affect all controls associated with the datamanager. So if the VisibleDates of day/scheduleview contains 2/25/2011, you would see the timeslots (and any activity) for 2/25/2011 6:00am to 2/26/2011 6am. If you had a xamMonthView showing the weeks for Feb 2011 and you look at Thursday 2/25/2011, you would see any activity that intersects 2/25/2011 6:00am to 2/26/2011 6am. If you had an activity that started on 2/25/2011 5:00am and end on 2/25/2011 5:30 am, it would show up under Wed 2/24/2011.
Thanks Andrew,
Sorry i am new to .net and WPF.
I have trie it by setting
dataManager.Settings.LogicalDayOffset = new System.TimeSpan(6, 0, 0);
bu i keep getting exception 'Object reference not set to an instance of an object.'
Hope you can help if i am doing something very stupid.
Hi Andrew,
I am trying to achieve a similar thing. I need to store Appointment Type info in each TimeSlot. Is there a way to set DataItem for each TimeSlot?
No, timeslots are generated by the control based on the visible dates, timeslotinterval, logical day offset/duration, etc. so there is no source collection or underlying dataitems. Really these are placeholder elements for where the activity will be created/positioned. If you needed to store some information on a per timeslot basis then likely you would need to create some attached properties/behaviors and set that using a custom style for the desired elements (e.g. TimeslotPresenter). You can submit a suggestion describing the functionality that you would like to see added.
Hi,
Can you shed some light on how I can achieve this with "creating some attached propertes and setting that in sustom style? I have downloaded the source code, but a alot of the classes are marked as internal.
The source isn't really going to help you with creating attached properties; that is just general WPF functionality. What I was describing was an attached property so that you could set some custom information on the timeslot and then in theory you would retemplate the timeslot elements to make use of that information however you needed.
In the simple project attached I'm just evaluating the start/end to see if it intersects with lunch time (in this case a fixed time range). So for that I have a simple enum that I will set on the timeslot elements:
public enum TimeslotType { NonWorkingTime, WorkingTime, LunchTime, }
You would define an attached property that will hold whatever information you need to have access to in the element.
#region TimeslotType public static readonly DependencyProperty TimeslotTypeProperty = DependencyProperty.RegisterAttached("TimeslotType", typeof(TimeslotType), typeof(ScheduleData), new FrameworkPropertyMetadata((TimeslotType)TimeslotType.WorkingTime)); public static TimeslotType GetTimeslotType(DependencyObject d) { return (TimeslotType)d.GetValue(TimeslotTypeProperty); } public static void SetTimeslotType(DependencyObject d, TimeslotType value) { d.SetValue(TimeslotTypeProperty, value); } #endregion //TimeslotType
public static readonly DependencyProperty TimeslotTypeProperty = DependencyProperty.RegisterAttached("TimeslotType", typeof(TimeslotType), typeof(ScheduleData), new FrameworkPropertyMetadata((TimeslotType)TimeslotType.WorkingTime));
public static TimeslotType GetTimeslotType(DependencyObject d) { return (TimeslotType)d.GetValue(TimeslotTypeProperty); }
public static void SetTimeslotType(DependencyObject d, TimeslotType value) { d.SetValue(TimeslotTypeProperty, value); }
#endregion //TimeslotType
Now since you likely want to use the Start/End of the timeslot to make your determine you would probably create a multibinding to get the state information so you'll need a multivalueconverter that will take the information and return the state information that you want to attach. Note: As with any multibinding you'll want to bind to every property whose change could affect the result because the multibinding will only be evaluated whenever the value of one of the properties in the binding have been changed.
public class TimeslotTypeValueConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (values == null || values.Length != 4) return DependencyProperty.UnsetValue; if (values[0] is ScheduleData == false || values[1] is DateTime == false || values[2] is DateTime == false || values[3] is Boolean == false) return DependencyProperty.UnsetValue; ScheduleData data = values[0] as ScheduleData; DateTime startTime = (DateTime)values[1]; DateTime endTime = (DateTime)values[2]; bool isWorkingHour = (bool)values[3]; return data.GetTimeslotType(startTime, endTime, isWorkingHour); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return new object[] { DependencyProperty.UnsetValue }; } }
if (values[0] is ScheduleData == false || values[1] is DateTime == false || values[2] is DateTime == false || values[3] is Boolean == false) return DependencyProperty.UnsetValue;
ScheduleData data = values[0] as ScheduleData; DateTime startTime = (DateTime)values[1]; DateTime endTime = (DateTime)values[2]; bool isWorkingHour = (bool)values[3];
return data.GetTimeslotType(startTime, endTime, isWorkingHour); }
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return new object[] { DependencyProperty.UnsetValue }; } }
Then you need a multibinding that will use that converter. You could set the multibinding on something inside your custom TimeslotPresenter template or you could do it in your style. I chose the latter:
<Window.Resources> <local:TimeslotTypeValueConverter x:Key="timeslotConverter" /> <Style TargetType="igPrim:TimeslotPresenter"> <Setter Property="local:ScheduleData.TimeslotType"> <Setter.Value> <MultiBinding Converter="{StaticResource timeslotConverter}"> <Binding Path="DataContext" RelativeSource="{RelativeSource AncestorType={x:Type Window}}" /> <Binding Path="Start" RelativeSource="{RelativeSource Self}" /> <Binding Path="End" RelativeSource="{RelativeSource Self}" /> <Binding Path="IsWorkingHour" RelativeSource="{RelativeSource Self}" /> </MultiBinding> </Setter.Value> </Setter> </Style> </Window.Resources>
Then you need a custom template that will make use of that information. In this case I'll just change the Background when its lunch time and the timeslot is not selected. Note: You can find the default styles/templates in the DefaultStyles directory (e.g. in the C:\Program Files\Infragistics\NetAdvantage 2011.1\WPF\DefaultStyles\Schedule directory) and use that as the basis for your custom templates/styles.
<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="igPrim:TimeslotPresenter"> <Grid> <Border x:Name="Border" BorderBrush="{TemplateBinding ComputedBorderBrush}" BorderThickness="{Binding Path=Orientation, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource tsOrientationToThicknessConverter}}" Background="{TemplateBinding ComputedBackground}" Padding="{TemplateBinding Padding}" igPrim:XamlHelper.SnapsToDevicePixels="True"> </Border> <Border x:Name="DayBorder" BorderBrush="{TemplateBinding DayBorderBrush}" BorderThickness="{TemplateBinding DayBorderThickness}" Visibility="{TemplateBinding DayBorderVisibility}" igPrim:XamlHelper.SnapsToDevicePixels="True"> </Border> </Grid> <ControlTemplate.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="IsSelected" Value="False" /> <Condition Property="local:ScheduleData.TimeslotType" Value="LunchTime" /> </MultiTrigger.Conditions> <Setter TargetName="Border" Property="Background" Value="DarkGray" /> </MultiTrigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter>
That sample app was very useful. It got me started thinking on how to go about implementing my requirements.
Hi Stefan,
I actually found the way to do this. All I needed is to get the list of timeslots and update binding. That was all.
Thanks for you help
Hello Steven,
it seems like that I am missing something in your scenario, so feel free to modify the sample I sent you, so it reproduces your behavior and send it back to me for further investigation.
Looking forward for your reply.
Andrew's example is about TimeSlots not Appointments. I was asking about how to trigger the TimeSlot to refresh.
Does my question make sense?
Best Regards,
Steven
I have modified the sample Andrew uploaded, so now there is a Button which changes the Properties of one of the Appointments and everything seems to update properly on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
What I meant is that the sample given works fine when the timeslot gets created it binds to the custom properties.
But what if the custom properties changes and we need to time slot to rebind?