翻译|使用教程|编辑:陈津勇|2019-11-19 10:22:22.023|阅读 265 次
概述:本文详细介绍了使用DotNetBar for Silverlight用户界面工具箱在Silverlight计划中自定义Appointment Views的操作步骤。
# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>
DotNetBar for Silverlight是一个能帮助用户创建专业Silverlight应用程序的用户界面工具箱,它包含了Calendar/Scheduler控件、径向菜单、超级工具提示等。本文详细介绍了在Silverlight计划中自定义Appointment Views的操作步骤。
免费下载DotNetBar for Silverlight正式版
可以在全局级别、每个日历视图(即日、周、月或时间轴)和/或每个预约的基础上自定义Appointment Views。
使用Appointment.ViewDefinitions属性可以在每个约定的基础上定义自定义项。
使用CalendarModel.AppointmentViewDefinitions属性或CalendarView.ViewCustomizations可以在全局级别上定义自定义项。
CalendarView.ViewCustomizations是CalendarViewCustomizations类型的属性,而该属性又具有三个用于自定义日历视图不同方面的属性:GlobalAppointmentViewDefinitions,DayTimeSlotAppearances和MonthDayAppearances。若要自定义预定视图,请使用GlobalAppointmentViewDefinitions属性。
注意:预定视图的尺寸(宽度和高度)在内部设置。在“月”视图、“时间轴”视图、“周”和“天”视图中的多日预约的高度是不变的。使用的值在ScheduleSettings(DevComponents.Silverlight.Schedule)中定义,并且可以在运行时更改。其属性和默认值是:MonthViewAppointmentHeight = 18,TimelineViewAppointmentHeight = 21,WeekViewMultiDayAppointmentHeight = 18。
定义一组appointment视图自定义项的类型是AppointmentViewDefinitionSet。虽然AppointmentViewDefinitionSet是AppointmentViewDefinition实例的集合,但它也暴露了以下依赖项属性,这些属性可用于为所有日历视图中的预约设置视图属性:
CommonBackground –用于所有视图类型(日、周、月和时间轴)中预约背景的画笔
CommonBorderBrush –一种画笔,用于所有视图类型中的预约边框。
CommonCornerRadius –用于所有视图类型的预约的CornerRadius。
CommonToolTip –用于所有视图类型的预约的工具提示。其值可以是DevComponents.Silverlight.Controls.SuperToolTip或System.Windows.Controls.ToolTip的实例。或是任何Clr对对象,在这种情况下,值被设置为SuperToolTip的内容。
CommonImageSource –用于所有视图类型的预约的图像。值可以是指定图像位置的字符串或Uri,也可以是ImageSource对象。
CommonSelectionBorderBrush –选择预约时所有视图类型中预约边框的画笔。
通过类AppiontmentViewDefinition支持在每个日历视图基础上设置属性。定义集中设置的值总是优先于定义集中定义的对应值。定义集公开了类型为AppointmentViewDefinition的四个属性,每个日历视图类型各有一个属性:日、周、月和时间线。appointment视图定义公开以下依赖项属性:
AppointmentTemplate –定义一个数据模板,用作AppointmentView控件的ContentTemplate。AppointmentView控件是一个ContentControl。默认情况下,Content属性设置为等于DataContext属性,该属性是DevComponents.Silverlight.Calendar.ViewModel.AppointmentViewModel的实例。
Background –定义用于appointment视图背景的笔刷。如果设置了Appointment.CategoryColor的有效值,则忽略此值。
BorderBrush –定义用于appointment视图边框的画笔。如果将Appointment.CategoryColor的值设置为内置值之一,则忽略此值。
CornerRadius –定义appointment视图的拐角半径。默认值为0。
CustomData –放置自定义数据对象的位置,然后可以在AppointmentTemplate和/或ToolTipTemplate中对其进行绑定。
ImageSource –指定要与预约关联的图像。值可以是指定图像位置的字符串或Uri,也可以是ImageSource对象。
MultiDayAppointmentTemplate –定义一个DataTemplate用于多日预约的视图。注意:对于“月”和“时间轴”视图,如果在提供AppointmentTemplate的值时未设置此值,则AppointmemtTemplate的值将用于所有预约,包括单日和多日。
SelectionBorderBrush –选中时用于预约边框的画笔。默认值由资源提供,键为“AppointmentSelectedBorderBrush”。
ToolTip–与适用视图中的预约相关联的工具提示。此值可以是DevComponents.Silverlight.Controls.SuperToolTip或System.Windows.Controls.ToolTip的实例。或者,它可以是任何Clr对象,在这种情况下,值被设置为SuperToolTip的内容。
ToolTipTemplate – 用于appointment视图创建的SuperToolTip的ContentTemplate。默认情况下,将创建一个SuperToolTip,并将其content属性设置为与预约关联的AppointmentViewModel实例。如果未设置此值,则默认工具提示内容模板由具有静态属性AppointmentView.DefaultToolTipContentTemplateKey定义的键的资源定义,其默认值为“ StandardAppointmentToolTipTemplate”。
注意,可以从AppointmentViewDefinitionSet和AppointmentViewDefinition之一或两者中派生出更大的自定义可能性。为了支持这个场景,属性AppointmentViewDefinition.CurrentView将始终包含AppointmentViewModel的活跃实例,该实例为当前视图提供数据,可用于运行时属性修改。
免费下载DotNetBar for Silverlight正式版
完全支持属性继承。最高优先级是appointment视图定义提供的值,这些定义取自直接应用于预约的定义集。下一个最高优先级是在预约定义上设置的值,这些值取自通过日历控件本身直接或间接应用到日历模型的全局定义集。如果它们都不具有值集,则将检查定义集提供的公用值,并将对直接应用于约会的集合上的值设置优先于全局集合的值。
这是在单个预约中设置要用于周视图和日视图的图像的示例:
字符串 url = “ images / don.png” ; 如果 (预约。ViewDefinitions == 空) 预约。ViewDefinitions = new AppointmentViewDefinitionSet (); 任命。ViewDefinitions 。天。ImageSourceUri =约会。ViewDefinitions 。周。ImageSourceUri = 新的 Uri (网址,UriKind 。相对);
全局appointment视图定义集可以在Xaml中定义和应用。这是从样例ScheduleControlMVVMSample获取并在Xaml中设置,且应用的全局定义集的示例:
<时间表:CalendarViewCustomizations X:键 = “ViewCustomizations” > <时间表:CalendarViewCustomizations.GlobalAppointmentViewDefinitions > <时间表:AppointmentViewDefinitionSet > <时间表:AppointmentViewDefinitionSet.CommonToolTip > <控件:SuperToolTip 样式 = “{StaticResource的AppointmentToolTipStyle}” /> </时间表:AppointmentViewDefinitionSet .CommonToolTip > <schedule:AppointmentViewDefinitionSet.Day > <schedule:AppointmentViewDefinition AppointmentTemplate = “ {StaticResource CustomDayViewAppointmentTemplate}” /> </schedule:AppointmentViewDefinitionSet.Day > </ schedule:AppointmentViewDefinitionSet > </schedule:CalendarViewCustomizations.GlobalAppointmentViewDefinitions > </ schedule:CalendarViewCustomizations >
通过将ViewCustomizations属性设置为以下方式,将该自定义应用于CalendarView:
ViewCustomizations =“ {StaticResource CalendarViewCustomizations}”
Appointment View模型
Appointment - 视图模型是其包装器的实际预约实例。
ViewDefinition – 有效的预约视图定义。该实例基于继承链将所有属性绑定到最相关的源。
ImageSource –获取或设置由Image的ImagesSource属性绑定的值。默认情况下,它将在有效Appointment视图定义上返回ImageSource的值,或者返回null。
OwnerKey –获取或设置预约所有者的Key。有效地设置此值将更改预约的所有者。
Owner –获取类Owner的实例,该类代表预约的所有者。
IsLocked –获取或设置预约的Locked属性。
IsSelected –获取或设置预约的IsSelected属性。
IsRecurrenceRoot –获取预约是否为重复的根预约。
IsRecurring –获取预约是否为重复预约的一部分。
StartTime –获取或设置预约的开始时间。
EndTime –获取或设置预约的结束时间。
Subject–获取或设置预约的主题。
Description–获取或设置预约的说明。
CategoryColor –获取或设置预约CategoryColor的值。
TimeMarkedAs –获取或设置预约TimeMarkedAs的值。
CornerRadius –获取预约视图的角半径。
SelectionBorderBrush –选择预约时获取用于边框的画笔。
Background–获得有效的预约背景画笔。
BorderBrush –获取预约的有效边框笔刷。
TimeMarkerBrush –获取用于时间标记的有效画笔。
CurrentViewType –获取当前活动视图(例如Month、Week、Day或Timeline)的CalendarViewType。
默认模板
默认的AppointmentView和ToolTip ContentTemplates在运行时合并到当前应用程序的资源字典中。系统提供了一些默认模板,您可以用它们来自定义模板。
请注意,可以通过在Application.Resources部分中使用相同的键定义一个新值来覆盖所有默认模板。这是在全局级别上自定义预约的另一种方法。
Appointment View模板
<!-定义用于“月”视图中约会的默认DataTemplate。-> <DataTemplate x:Key = “ MonthViewAppointmentTemplate” > <TextBlock Margin = “ 5,0,1,0” > <Run Text = “ {Binding Subject}” /> <Run Text = “ {Binding StartTime,StringFormat = '{0:t}'}“ /> </ TextBlock > </ DataTemplate > <!-在月视图中为多日约会定义默认的DataTemplate。-> <DataTemplate x:Key = “ -在“周”或“天”视图中使用约会的默认DataTemplate。 -> <DataTemplate x:Key = “ WeekViewAppointmentTemplate” > <网格> <Grid.ColumnDefinitions > <ColumnDefinition Width = “自动” /> <ColumnDefinition Width = “自动” /> <ColumnDefinition /> </Grid.ColumnDefinitions > <Grid.RowDefinitions > < RowDefinition Height = “ Auto” /> <RowDefinition /> </Grid.RowDefinitions > <Border Grid.RowSpan = “ 2” 宽度 = “ 5” HorizontalAlignment =“左” BorderThickness = “ 0,0,1,0” CornerRadius = “ {Binding CornerRadius}” BorderBrush = “ {Binding BorderBrush}” 背景 = “ {Binding TimeMarkerBrush}” 可见性 = “ {Binding TimeMarkerVisibility}” /> <图像保证金 = “ 3,3,0,0” Grid.Column = “ 1” HorizontalAlignment = “ Left” VerticalAlignment = “ Top” MaxHeight = “ 20” MaxWidth = “ 20”拉伸 = “均匀” 来源 = “ {Binding ViewDefinition.ImageSource}” 可见性 = “ {Binding ViewDefinition.ImageSource,Converter = {StaticResource nullableToVisibilityConverter}}” /> <TextBlock Grid.Column = “ 2” Margin = “ 3,3,0,0” TextWrapping = “ Wrap“ Text = ” {Binding Subject}“ /> <TextBlock Margin = ” 3,3,0,0“ Grid.Row = ” 1“ Grid.Column = ” 1“ Grid.ColumnSpan = ” 3“ TextWrapping = ”包装”文字 = “ {绑定说明}” /> </ Grid > </ DataTemplate > <!-在“周”或“天”视图中定义多天约会的默认数据模板。-> <DataTemplate x:Key = “ WeekViewMultiDayAppointmentTemplate” > <TextBlock 保证金 = “ 10,0,5,0” HorizontalAlignment = “左” > <运行 文本 = “ {绑定主题}” /> <运行 文本 = “ { Binding StartTime,StringFormat ='{0:MMMM dd}'}“ /> <Run Text = ” {Binding EndTime, Text = “ {Binding StartTime,StringFormat ='-{0:t}'}} /> /> <Run Text = ” {Binding EndTime,StringFormat ='to {0:t}'}“ /> </ TextBlock > </ DataTemplate > <!-在“时间轴”视图中定义约会的默认数据模板。-> <DataTemplate x:Key = “ TimelineViewAppointmentTemplate” > <TextBlock Margin = “ 10,0,5,0” HorizontalAlignment = “左” > <Run Text = “ {Binding Subject}” /> “ {Binding StartTime,StringFormat ='{0:MMMM dd}'}” /> <运行 文本 = “ {Binding EndTime,StringFormat ='thru {0:MMMM dd}'}” /> <Run Text = “ {Binding StartTime,StringFormat ='-{0:t}'}“ /> <Run Text = ” {绑定EndTime,StringFormat ='至{0:t}'}“ /> </ TextBlock > </ DataTemplate >
工具提示模板
<!-在“日”,“周”和“时间轴”视图中为约会工具提示定义默认的DataTemplate。-> <DataTemplate x:Key = “ StandardAppointmentToolTipTemplate” > <Grid MaxWidth = “ 300” > <Grid.RowDefinitions > <RowDefinition Height = “ Auto” /> <RowDefinition Height = “ Auto” /> <RowDefinition Height = “ Auto “ /> </Grid.RowDefinitions > <TextBlock Text = ” {Binding Subject}“ <TextBlock Grid.Row = “ 1” > <运行 文本 = “ {Binding StartTime,StringFormat ='t'}” /> <Run Text = “ {Binding EndTime,StringFormat ='to {0:t}'}” / > </ TextBlock > <TextBlock Grid.Row = “ 2” Text = “ {Binding Description}” TextWrapping = “ Wrap” /> </ Grid > </ DataTemplate > <!-定义月约会视图的默认DataTemplate工具提示-> <DataTemplate x:Key = “ MonthCalloutToolTipTemplate” > <Grid > <Grid.ColumnDefinitions > <ColumnDefinition Width = “ Auto” /> <ColumnDefinition /> <ColumnDefinition Width = “ Auto” /> </Grid.ColumnDefinitions > <Grid.RowDefinitions > <RowDefinition /> <RowDefinition /> < RowDefinition /> </Grid.RowDefinitions > <边框 高度 = “ 10” 宽度 = “ 10” HorizontalAlignment = “中心” VerticalAlignment = “中心” CornerRadius = “ 3” BorderThickness = “ 1” 背景 = “ {绑定背景}” BorderBrush = “ {Binding BorderBrush}” /> <TextBlock Grid.Column = “ 1” 保证金 = “ 7,0,8,0” HorizontalAlignment = “左” 文本 = “ {绑定主题}” FontWeight = “粗体” TextWrapping = “包装” ctrls:DynamicResource.ForegroundKey = “ CalloutSubjectForeground” /> <TextBlock Margin = “ 0,0,5,0” Grid.Column = “ 2” HorizontalAlignment = “ Right” ctrls:DynamicResource.ForegroundKey = “ CalloutTimeForeground” > <Run Text = “ {Binding StartTime,StringFormat ='t'}” /> <Run Text = “ {Binding EndTime,StringFormat ='至{0:t}'}“ /> </ TextBlock > <Line Grid.ColumnSpan = ” 3“ Grid.Row = ” 1“ 裕度 = ” 0,3“ StrokeThickness = ” 1“ X1 = “ 0” X2 = “ 1” Y1 =“ 0” Y2 = “ 0” Stretch = “填充” ctrls:DynamicResource.StrokeKey = “ CalloutSeparatorBorder” 可见性 = “ {绑定说明,转换器= {StaticResource nullableToVisibilityConverter}}” /> <Grid Grid.Row = “ 2” 网格。 ColumnSpan = “ 3” > <Grid.ColumnDefinitions > <ColumnDefinition Width = “自动” /> <ColumnDefinition /> </Grid.ColumnDefinitions > <图像边距 = “ 0,0,5,0” VerticalAlignment = “ Top” MaxHeight = “ 20” MaxWidth = “ 20” Stretch = “ Uniform” 源 = “ {Binding ImageSource}” 可见性 = “ {Binding ImageSource,Converter = {StaticResource nullableToVisibilityConverter}}” /> <TextBlock MaxWidth = “ 370” Grid.Column = “ 1” VerticalAlignment = “居中” Text = “ {装订说明}” TextWrapping = “包装” HorizontalAlignment = “左”ctrls:DynamicResource.ForegroundKey = “ CalloutDescriptionForeground” /> </ Grid > </ Grid > </ DataTemplate >
基于AppointmentView的控件的默认样式和模板
如果有必要,可以使用Silverlight提供的隐式样式继承,通过AppointmentView控件的Style属性来修改预约视图。注意,使用预约视图的隐式样式只能在全局级别上自定义预约。不能为单个预约的视图提供自定义样式或模板。
AppointmentView控件是从AppointmentView派生的控件– AppointmentView本身是一个抽象类。为每种日历视图类型定义了特定的约会视图控件。具体的AppointmentView控件是:
Month Appointmemt View – 在“月”视图中提供单日预约的视图。
MonthMultiDaySegmentAppointmentView –在“月”视图中提供多天预约的一部分视图。一个段代表一个星期包含的预约的时间跨度。
Week Appointment View –在“周”和“日”视图中提供一天预约的视图。
Week MultiDay Appointment View –在“周”和“天”视图中提供多天预约的视图。
Timeline Appointment View –在“时间轴”视图中提供预约的视图。
为方便,系统提供了默认控件模板。您可以使用它们进行自定义。
Month Appointment View控件模板
Month Appointment View的默认控件模板:
<ControlTemplate TargetType = “ sch:MonthAppointmentView” > <网格> <边框 背景 = “ {Binding Background}” BorderBrush = “ {Binding BorderBrush}” BorderThickness = “ 1” CornerRadius = “ {Binding CornerRadius}” /> <ContentPresenter VerticalAlignment = “ Center” Content = “ {TemplateBinding DataContext}” ContentTemplate = “ {TemplateBinding AppointmentTemplate}” /> <边框 名称 = “ SelectedBorder” BorderThickness= “ 2” BorderBrush = “ {Binding SelectionBorderBrush}” 不透明度 = “ 0” CornerRadius = “ {Binding CornerRadius}” /> <sch:MonthAppointmentMoveThumb x:Name = “ MoveThumb” /> <VisualStateManager.VisualStateGroups > <VisualStateGroup x:Name = “ SelectedStates” > <VisualState x:Name = “未选择” /> <VisualState x:Name = “ Selected” > <故事板> <DoubleAnimation Storyboard.TargetName =“ SelectedBorder” Storyboard.TargetProperty = “ Opacity” To = “ 1” 持续时间 = “ 0:0:0.01” /> </ Storyboard > </ VisualState > </ VisualStateGroup > <VisualStateGroup x:Name = “ RecurrenceStates” > <VisualState x:Name = “ NonRecurring” /> <VisualState x:Name = “ RecurrenceRoot” /> <VisualState x:Name = “ RecurringInstance” > <故事板> <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ MoveThumb” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Collapsed” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > </VisualStateManager.VisualStateGroups > </ Grid > </ ControlTemplate >
Month MultiDay Segment Appointment View的默认控件模板:
<ControlTemplate TargetType = “ sch:MonthMultiDaySegmentAppointmentView” > <网格> <边框 名称 = “ NormalBorder” 背景 = “ {绑定背景}” BorderBrush = “ {Binding BorderBrush}” BorderThickness = “ 1” CornerRadius = “ {Binding CornerRadius}” / > <ContentPresenter Content = “ {TemplateBinding DataContext}” ContentTemplate = “ {TemplateBinding AppointmentTemplate}” VerticalAlignment = “中心” /> <边框 名称= “ SelectedBorder” BorderThickness = “ 2” BorderBrush = “ {Binding SelectionBorderBrush}” 不透明度 = “ 0” CornerRadius = “ {Binding CornerRadius}” /> <sch:MonthAppointmentMoveThumb x:Name = “ MoveThumb” /> <Grid Name = “ MoveResizeGroup“ 可见性 = ”崩溃“ > <sch:MonthAppointmentResizeThumb x:Name = ” ResizeLeft“ 保证金 = ” -2,0,0,0“ HorizontalAlignment = “左” 可见性 =“ Collapsed” /> <sch:MonthAppointmentResizeThumb x:Name = “ ResizeRight” Margin = “ 0,0,-2,0” HorizontalAlignment = “ Right” Visibility = “ Collapsed” /> </ Grid > <VisualStateManager.VisualStateGroups > < VisualStateGroup x:Name = “ SelectedStates” > <VisualState x:Name = “未选择” /> <VisualState x:Name = “ Selected” > <故事板> <DoubleAnimation Storyboard.TargetName =“ SelectedBorder” Storyboard.TargetProperty = “不透明度” To = “ 1” 持续时间 = “ 0:0:0” /> <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ MoveResizeGroup” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “可见” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > <VisualStateGroup x:Name =“ RecurrenceStates” > <VisualState x:Name = “ NonRecurring” /> <VisualState x:Name = “ RecurrenceRoot” /> <VisualState x:Name = “ RecurringInstance” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” 故事板。 TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “已崩溃” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ResizeRight” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “0” 值 = “折叠” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “MoveThumb” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “已崩溃” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > <VisualStateGroup x:Name = “ BoundaryStates” > <VisualState x:Name = “ Closed” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame > KeyTime = “ 0” 值 = “ Visible” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeRight” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Visible” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = “ OpenRight” > <Storyboard > <ObjectAnimationUsingKeyFrames 故事板.TargetName = “ NormalBorder” 故事板。TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 =“ 1,1,0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 2,2,0,2” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 =“ Visible” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = “ OpenLeft” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1,1,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,2,2,2” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeRight” Storyboard.TargetProperty = “ Visibility” > < DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Visible” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:名称= “ OpenBothEnds” > <故事板> <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames 故事。 = “ SelectedBorder” 故事板。TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 =“ 0,2” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > </VisualStateManager.VisualStateGroups > </ Grid > </ ControlTemplate >
Day/Week Appointment View控制模板
Week Appointment View的默认控件模板:
<ControlTemplate TargetType="sch:WeekAppointmentView"> <Grid> <Grid.Resources> <ctrls:BoolToVisibilityConverter x:Key="boolToVisibilityConverter" /> </Grid.Resources> <Border Background="{Binding Background}" BorderBrush="{Binding BorderBrush}" BorderThickness="1" CornerRadius="{Binding CornerRadius}" /> <ContentPresenter Content="{TemplateBinding DataContext}" ContentTemplate="{TemplateBinding AppointmentTemplate}" /> <Border Name="SelectedBorder" Background="Transparent" BorderThickness="2" Opacity="0" BorderBrush="{Binding SelectionBorderBrush}" CornerRadius="{Binding CornerRadius}" /> <sch:WeekAppointmentMoveThumb x:Name="MoveThumb" Margin="0,4" Cursor="Hand" Visibility="{Binding Path=IsLocked, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Inverse}" /> <Grid Name="MoveResizeGroup" Visibility="{Binding Path=IsLocked, Converter={StaticResource boolToVisibilityConverter}, ConverterParameter=Inverse}" > <sch:WeekAppointmentMoveThumb x:Name="ResizeTop" Opacity="0" VerticalAlignment="Top" Margin="0,-2,0,0" Cursor="SizeNS" Style="{StaticResource ResizeThumbStyle}" /> <sch:WeekAppointmentMoveThumb x:Name="ResizeBottom" Opacity="0" VerticalAlignment="Bottom" Margin="0,0,0,-2" Cursor="SizeNS" Style="{StaticResource ResizeThumbStyle}" /> </Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="SelectedStates"> <VisualState x:Name="Unselected" /> <VisualState x:Name="Selected"> <Storyboard> <DoubleAnimation Storyboard.TargetName="ResizeTop" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> <DoubleAnimation Storyboard.TargetName="ResizeBottom" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> <DoubleAnimation Storyboard.TargetName="SelectedBorder" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> </Storyboard> </VisualState> </VisualStateGroup> <VisualStateGroup x:Name="RecurrenceStates"> <VisualState x:Name="NonRecurring" /> <VisualState x:Name="RecurrenceRoot" /> <VisualState x:Name="RecurringInstance"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ResizeTop" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ResizeBottom" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" /> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MoveThumb" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" /> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </ControlTemplate>
Week MultiDay Appointment View的默认控件模板:
<ControlTemplate TargetType = “ sch:WeekMultiDayAppointmentView” > <网格> <边框 名称 = “ NormalBorder” 背景 = “ {绑定背景}” BorderBrush = “ {Binding BorderBrush}” BorderThickness = “ 1” CornerRadius = “ {Binding CornerRadius}” / > <ContentPresenter Content = “ {TemplateBinding DataContext}” ContentTemplate = “ {TemplateBinding AppointmentTemplate}” /> <边框 名称 = “ SelectedBorder” BorderThickness= “ 2” BorderBrush = “ {Binding SelectionBorderBrush}” 不透明度 = “ 0” CornerRadius = “ {Binding CornerRadius}” /> <VisualStateManager.VisualStateGroups > <VisualStateGroup x:Name = “ SelectedStates” > <VisualState x:Name = “未选择“ /> <VisualState x:Name = ”已选择“ > <Storyboard > <DoubleAnimation Storyboard.TargetName = ” SelectedBorder“ 故事板。TargetProperty = “不透明度” 至= “ 1” 持续时间 = “ 0:0:0.01” /> </ Storyboard > </ VisualState > </ VisualStateGroup > <VisualStateGroup x:Name = “ BoundaryStates” > <VisualState x:Name = “ Closed” /> <VisualState x:Name = “ OpenRight” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime =“ 0” 值 = “ 1,1,0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 2,2 ,0,2“ /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = ” OpenLeft“ > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1,1,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” 故事板。 TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,2,2,2” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = “ OpenBothEnds” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “BorderThickness“ > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,2” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > </VisualStateManager.VisualStateGroups > </ Grid > </ ControlTemplate >
Timeline Appointment View控件模板
Timeline Appointment View的默认控件模板:
<ControlTemplate TargetType = “ sch:TimelineAppointmentView” > <网格> <边框 名称 = “ NormalBorder” 背景 = “ {绑定背景}” BorderBrush = “ {Binding BorderBrush}” BorderThickness = “ 1” CornerRadius = “ {Binding CornerRadius}” / > <ContentPresenter Content = “ {TemplateBinding DataContext}” ContentTemplate = “ {TemplateBinding AppointmentTemplate}” VerticalAlignment = “ Center” /> <边界 名称 =“ SelectedBorder” 背景 = “ {Binding BackgroundBrush}” BorderThickness = “ 2” BorderBrush = “ {Binding SelectionBorderBrush}” 不透明度 = “ 0” CornerRadius = “ {Binding CornerRadius}” /> <sch:TimelineAppointmentMoveThumb x:Name = “ MoveThumb” 保证金 = “ 4,0” 光标 = “手” /> <网格 名称 = “ MoveResizeGroup” 可见性 = “已崩溃” > <sch:TimelineAppointmentMoveThumb x:Name =“ ResizeLeft” HorizontalAlignment = “左” 保证金 = “ -2,0,0,0” 游标 = “ SizeWE” 样式 = “ {StaticResource ResizeThumbStyle}” /> <sch:TimelineAppointmentMoveThumb x:Name = “ ResizeRight” HorizontalAlignment = “ Right “ 保证金 = ” 0,0,-2,0“ 游标 = ” SizeWE“ 样式 = ” {StaticResource ResizeThumbStyle}“ /> </ Grid > <VisualStateManager.VisualStateGroups > <VisualStateGroup x:Name = “ SelectedStates”> <VisualState x:Name = “未选择” /> <VisualState x:Name = “已选择” > <Storyboard > <DoubleAnimation Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ Opacity” To = “ 1” 持续时间 = “ 0 :0:0“ /> <DoubleAnimation Storyboard.TargetName = ” NormalBorder“ Storyboard.TargetProperty = ”不透明度“ To = ” 0“ 持续时间 = “ 0:0:0” /> <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ MoveResizeGroup” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame KeyTime = “ 0” Value = “ Visible” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > </ VisualStateGroup > <VisualStateGroup x :Name = “ RecurrenceStates” > <VisualState x:Name = “ NonRecurring” /> <VisualState x:名称= “ RecurrenceRoot” /> <VisualState x:Name = “ RecurringInstance” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame KeyTime = “ 0” Value = “ Collapsed” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUs Storyboard.TargetName = “ ResizeRight” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “折叠” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “MoveThumb” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “0” 值 = “折叠” /> </ ObjectAnimationUsingKeyFrames > </故事板> </ VisualState > </ VisualStateGroup > <VisualStateGroup x:Name = “ BoundaryStates” > <VisualState x:Name = “已关闭” /> <VisualState x:Name = “ OpenRight” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 1,1,0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime= “ 0” 值 = “ 2,2,0,2” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeRight” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “崩溃” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = “ OpenLeft” > <故事板> <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1,1,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” 故事板。 TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,2,2,2” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” Storyboard.TargetProperty = “可见性” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Collapsed” /> </ ObjectAnimationUsingKeyFrames > </ Storyboard > </ VisualState > <VisualState x:Name = “ OpenBothEnds” > <Storyboard > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ NormalBorder” Storyboard.TargetProperty = “ BorderThickness”> <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,1” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ SelectedBorder” Storyboard.TargetProperty = “ BorderThickness” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ 0,2” / > </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeRight” Storyboard.TargetProperty = “可见性”> <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Collapsed” /> </ ObjectAnimationUsingKeyFrames > <ObjectAnimationUsingKeyFrames Storyboard.TargetName = “ ResizeLeft” Storyboard.TargetProperty = “ Visibility” > <DiscreteObjectKeyFrame KeyTime = “ 0” 值 = “ Collapsed” /> </ ObjectAnimationUsingKey > </ Storyboard > </ VisualState > </ VisualStateGroup > </VisualStateManager.VisualStateGroups > </ Grid > </ ControlTemplate>
想要获取DotNetBar for Silverlight更多资源或正版授权的伙伴请联系领取
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@cahobeh.cn
文章转载自: