翻譯|使用教程|編輯:陳津勇|2019-11-19 10:22:22.023|閱讀 314 次
概述:本文詳細介紹了使用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@fc6vip.cn
文章轉載自: