Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
XamScheduleView custom date format
posted

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,

  1. You can retemplate that element and modify it's contents - e.g. put in a TextBlock where the Text is bound to the Date property and set the StringFormat property of the Binding to whatever format you want to use. You can use the DefaultStyles we provide as a starting point for your custom template.

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>

Parents
No Data
Reply
  • 34810
    Verified Answer
    Offline posted

    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.

Children
No Data