This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
MainWindow.xaml
175 lines (173 loc) · 13.8 KB
/
MainWindow.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<dx:DXWindow x:Class="SchedulerBindToObservableCollectionWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler"
xmlns:dxscht="http://schemas.devexpress.com/winfx/2008/xaml/scheduler/themekeys"
xmlns:dxschd="clr-namespace:DevExpress.Xpf.Scheduler.Drawing;assembly=DevExpress.Xpf.Scheduler.v15.1"
xmlns:dxschdui="clr-namespace:DevExpress.Xpf.Scheduler.UI;assembly=DevExpress.Xpf.Scheduler.v15.1"
xmlns:local="clr-namespace:SchedulerBindToObservableCollectionWpf"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:mvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
Title="MainWindow" Height="800" Width="800">
<dx:DXWindow.DataContext>
<local:SchedulerViewModel/>
</dx:DXWindow.DataContext>
<dx:DXWindow.Resources>
<dxschd:ToolTipVisibilityToVisibilityConverter x:Key="ToolTipVisibilityConverter" />
<dx:BooleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
<dxschd:BrushResourcesConverter x:Key="brushResourcesConverter" />
<ControlTemplate x:Key="{dxscht:SchedulerViewThemeKey ResourceKey=VerticalAppointmentTemplate, IsThemeIndependent=True}" TargetType="{x:Type dxschd:VisualVerticalAppointmentControl}">
<dxschd:AppointmentColorConvertControl x:Name="clrConvCtrl" ControlColor="{Binding ViewInfo.LabelColor, RelativeSource={RelativeSource TemplatedParent} }" SnapsToDevicePixels="True">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="DraggedStates">
<VisualState x:Name="NotDragged">
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="back" To="0.8" Duration="0:0:0.15" />
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContentContainer" To="0.8" Duration="0:0:0.15" />
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Selection" To="0.8" Duration="0:0:0.15" />
</Storyboard>
</VisualState>
<VisualState x:Name="Dragged">
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="back" To="0.2" Duration="0:0:0.15" />
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContentContainer" To="0.2" Duration="0:0:0.15" />
<DoubleAnimation Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Selection" To="0.2" Duration="0:0:0.15" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<dxschd:AppointmentColorConvertControl.BaseColors>
<dxschd:ColorCollection>
<dxschd:ColorDefinition Value="#FFE4E4E4" Name="ColorDefinition_MiddleBorderGradient" />
<dxschd:ColorDefinition Value="#FFF0F0F0" Name="ColorDefinition_AppointmentBackgroundGradientStart" />
<dxschd:ColorDefinition Value="#FFE4E4E4" Name="ColorDefinition_AppointmentBackgroundGradientEnd" />
</dxschd:ColorCollection>
</dxschd:AppointmentColorConvertControl.BaseColors>
<dxschd:AppointmentColorConvertControl.BaseBrushColors>
<dxschd:ColorCollection>
<dxschd:ColorDefinition Value="#FFBABABA" Name="ColorDefinition_BackBorder" />
<dxschd:ColorDefinition Value="#FF7A7A7A" Name="ColorDefinition_AppointmentSelection" />
</dxschd:ColorCollection>
</dxschd:AppointmentColorConvertControl.BaseBrushColors>
<Grid x:Name="PART_ToolTipContainer" dxsch:SchedulerControl.HitTestType="AppointmentContent"
dxsch:SchedulerControl.SelectableIntervalViewInfo="{TemplateBinding ViewInfo}">
<ToolTipService.ToolTip>
<ToolTip Content="{TemplateBinding ViewInfo}"
ContentTemplate="{Binding ViewInfo.View.AppointmentToolTipContentTemplate, RelativeSource={RelativeSource TemplatedParent}}"
Visibility="{Binding ViewInfo.View.AppointmentToolTipVisibility, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ToolTipVisibilityConverter}}">
</ToolTip>
</ToolTipService.ToolTip>
<dxschd:AppointmentBorder x:Name="back" DefaultCornerRadius="4" Background="{Binding ElementName=clrConvCtrl, Path=Container, Converter={StaticResource brushResourcesConverter}, ConverterParameter=ColorDefinition_BackBorder}" Opacity="0.8" ViewInfo="{TemplateBinding ViewInfo}">
<dxschd:AppointmentBorder DefaultCornerRadius="3" DefaultMargin="1" ViewInfo="{TemplateBinding ViewInfo}">
<dxschd:LinearGradientBrushSetter.Info>
<dxschd:LinearGradientBrushInfo TargetProperty="Background" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop dxschd:LinearGradientBrushInfo.GradientStopColorId="ColorDefinition_AppointmentBackgroundGradientStart" Offset="0" />
<GradientStop dxschd:LinearGradientBrushInfo.GradientStopColorId="ColorDefinition_MiddleBorderGradient" Offset="1" />
</dxschd:LinearGradientBrushInfo>
</dxschd:LinearGradientBrushSetter.Info>
<dxschd:AppointmentBorder DefaultCornerRadius="2" DefaultMargin="1" ViewInfo="{TemplateBinding ViewInfo}" Background="{Binding ViewInfo.LabelBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
</dxschd:AppointmentBorder>
</dxschd:AppointmentBorder>
<Grid x:Name="ContentContainer" Margin="3,0,3,0">
<Grid.Resources>
<dxschd:AppointmentStatusDisplayTypeToGridLengthConverter x:Key="StatusDisplayTypeToGridLengthConverter" DefaultValue="5" />
<dxschd:AppointmentStatusDisplayTypeToVisibilityConverter x:Key="AppointmentStatusDisplayTypeToVisibilityConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ContentContainerStatusColumn" Width="{Binding StatusDisplayType, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource StatusDisplayTypeToGridLengthConverter}}" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<dxschdui:AppointmentStatusControl ViewInfo="{TemplateBinding ViewInfo}" Orientation="Vertical">
<dxschd:AppointmentBorder x:Name="Status" DefaultMargin="0,3,0,3" DefaultCornerRadius="2"
Background="{Binding ViewInfo.StatusBrush, RelativeSource={RelativeSource TemplatedParent}}"
ViewInfo="{TemplateBinding ViewInfo}"
Visibility="{Binding StatusDisplayType, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource AppointmentStatusDisplayTypeToVisibilityConverter}}"
/>
</dxschdui:AppointmentStatusControl>
<ContentPresenter x:Name="PART_Content" Grid.Column="1" Margin="10,6,10,0" Content="{TemplateBinding ViewInfo}" ContentTemplate="{TemplateBinding ContentTemplate}" />
</Grid>
<dxschd:AppointmentBorder x:Name="Selection" DefaultCornerRadius="4" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
DefaultBorderThickness="3" ViewInfo="{TemplateBinding ViewInfo}"
BorderBrush="Red"
Visibility="{Binding ViewInfo.Selected, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolToVisibilityConverter}}" />
<Rectangle Fill="Transparent" Height="5" VerticalAlignment="Top" HorizontalAlignment="Stretch"
Visibility="{Binding Path=ViewInfo.CanResizeStart, RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource boolToVisibilityConverter}}"
IsHitTestVisible="True"
dxsch:SchedulerControl.HitTestType="AppointmentResizingTopEdge"
dxsch:SchedulerControl.SelectableIntervalViewInfo="{TemplateBinding ViewInfo}"
Cursor="SizeNS">
</Rectangle>
<Rectangle Fill="Transparent" Height="5" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"
IsHitTestVisible="True"
Visibility="{Binding Path=ViewInfo.CanResizeEnd, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolToVisibilityConverter}}"
dxsch:SchedulerControl.HitTestType="AppointmentResizingBottomEdge"
dxsch:SchedulerControl.SelectableIntervalViewInfo="{TemplateBinding ViewInfo}"
Cursor="SizeNS">
</Rectangle>
</Grid>
</dxschd:AppointmentColorConvertControl>
</ControlTemplate>
</dx:DXWindow.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<dxsch:SchedulerControl Name="schedulerControl1" GroupType="Date" SelectedAppointmentsBindable="{Binding SelectedAppointments}">
<mvvm:Interaction.Behaviors>
<mvvm:EventToCommand EventName="Loaded" Command="{Binding SchedulerLoadedCommand}" PassEventArgsToCommand="True"/>
</mvvm:Interaction.Behaviors>
<dxsch:SchedulerControl.Storage>
<dxsch:SchedulerStorage Name="storage">
<dxsch:SchedulerStorage.AppointmentStorage>
<dxsch:AppointmentStorage DataSource="{Binding Appointments}" CommitIdToDataSource="True">
<dxsch:AppointmentStorage.Mappings>
<dxsch:AppointmentMapping
AppointmentId="Id"
Start="StartTime"
End="EndTime"
Subject="Subject"
Description="Description"
Location="Location"
AllDay="AllDay"
Label="Label"
Status="Status"
Type="EventType"
RecurrenceInfo="RecurrenceInfo"
ReminderInfo="ReminderInfo"
ResourceId="ResourceId"/>
</dxsch:AppointmentStorage.Mappings>
<dxsch:AppointmentStorage.CustomFieldMappings>
<dxsch:SchedulerCustomFieldMapping Member="Price" Name="Price" ValueType="Decimal"/>
</dxsch:AppointmentStorage.CustomFieldMappings>
</dxsch:AppointmentStorage>
</dxsch:SchedulerStorage.AppointmentStorage>
<dxsch:SchedulerStorage.ResourceStorage>
<dxsch:ResourceStorage DataSource="{Binding Resources}">
<dxsch:ResourceStorage.Mappings>
<dxsch:ResourceMapping
Id="Id"
Caption="Name"
Color="Color"/>
</dxsch:ResourceStorage.Mappings>
</dxsch:ResourceStorage>
</dxsch:SchedulerStorage.ResourceStorage>
</dxsch:SchedulerStorage>
</dxsch:SchedulerControl.Storage>
</dxsch:SchedulerControl>
<dxg:GridControl x:Name="gridControl" Grid.Row="1" SelectedItems="{Binding SelectedModelAppointments}" CurrentItem="{Binding CurrentModelAppointment, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" EnableSmartColumnsGeneration="True" AutoGenerateColumns="AddNew" SelectionMode="Row" AutoExpandAllGroups="True"
ItemsSource="{Binding Appointments}" FilterString="{Binding FilterString, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}">
<dxg:GridControl.View>
<dxg:TableView NavigationStyle="Row" ShowFilterPanelMode="ShowAlways">
<mvvm:Interaction.Behaviors>
<mvvm:EventToCommand EventName="RowDoubleClick" Command="{Binding ShowEditFormCommand}" PassEventArgsToCommand="True"/>
</mvvm:Interaction.Behaviors>
</dxg:TableView>
</dxg:GridControl.View>
<mvvm:Interaction.Behaviors>
<mvvm:EventToCommand EventName="FilterChanged" Command="{Binding FilterChangedCommand}" PassEventArgsToCommand="True"/>
</mvvm:Interaction.Behaviors>
</dxg:GridControl>
</Grid>
</dx:DXWindow>