Hello,
I am using a XamScheduleView and am attempting to make a custom template for the "igPrim:ScheduleViewDayHeader" as described in this post https://ko.infragistics.com/community/forums/f/ultimate-ui-for-wpf/61165/xamscheduleview-date-format. Andrew Smith wrote,
However, When I bind to the date property, it is repeating the same date for every visible date (see screenshot). Is this because it is a StaticResource? If not, is there a correct interpretation of Andrew's comment someone could elaborate on?
<ig:XamScheduleView x:Name="uiScheduleView" DataManager="{Binding ElementName=uiScheduleDataManager}" ShowWorkingHoursOnly="False" CalendarDisplayMode="Separate" TimeslotInterval="{Binding CPTimeslotIntervalTimeSpan}" MinCalendarGroupExtent="0" AllowDrop="True" Height="Auto"> <ig:XamScheduleView.Resources> <igPrim:ScheduleViewDayHeader x:Key="dayHeader"/> <Style TargetType="igPrim:ScheduleViewDayHeader"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <TextBlock x:Name="uiDateString" Text="{Binding Source={StaticResource dayHeader}, Path=Date}"></TextBlock> </ControlTemplate> </Setter.Value> </Setter> </Style> </ig:XamScheduleView.Resources> </ig:XamScheduleView>
Hello Casey,
I have been investigating into your requirement in this case, and you are correct that this is happening due to the StaticResource ScheduleViewDayHeader. By binding to its Date property, you are binding to the same instance of a ScheduleViewDayHeader that is not actually in the XamScheduleView.
Rather than doing this, I would recommend using a binding like the following for your text:
Text=”{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Date}”
This will bind to the ScheduleViewDayHeader element that you are re-templating for each TextBlock, and so the Date should reflect what it would have been in the control.
Please let me know if have any other questions or concerns on this matter.