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,
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>
Hi Stefan,
The TimeslotTypeValueConverter get triggered fine, if I scroll up and down the vertical scrollbar.
But similarly to http://es.infragistics.com/community/forums/t/84840.aspx
In DayView, I have set dayView.PreferredCalendarGroupExtent = 150;
Hence when there is a lot of ResourceCalendar visible, the 'TimeslotGroupScrollBar" will appear.
scrolling left and right this horizontal scrollbar DOES NOT trigger the TimeslotTypeValueConverter, hence I am showing timeslots that don't belong to the scrolled resource.
Is there a way to fix this? Thanks
Best Regards,
Steven
A converter of a Binding is only called when the source value changes or in the case of a multibinding when one of the values of one of the bindings has changed. Scrolling horizontally would not result in a change to the window's datacontext, the start time of the timeslot, the end time of the timeslot and typically not the IsWorkingHour state so what is happening is correct based on the bindings. If you want to account for when it's changed for a different calendar then you'll likely want to add another binding - e.g. for the DataContext of the timeslot itself since that would be the selected calendar of the containing calendar group. So add something like "<Binding Path="DataContext" RelativeSource="{RelativeSource Self}" />" to the end of the list of Bindings in the MultiBinding. You'll also need to update the converter because in the sample it is checking for a length of 4 values being provided. I attached an updated version of the sample from above but that's the only changes I made.
Hi Andrew,
thanks for the reply. This works fine now.