-
Notifications
You must be signed in to change notification settings - Fork 211
/
Copy pathOrderListPage.xaml
293 lines (275 loc) · 14.1 KB
/
OrderListPage.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!--
Copyright (c) Microsoft Corporation. All rights reserved.
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<Page
x:Class="Contoso.App.Views.OrderListPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="using:Contoso.Models"
xmlns:vm="using:Contoso.App.ViewModels"
xmlns:sys="using:System"
xmlns:toolkit="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:uc="using:Contoso.App.UserControls"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
NavigationCacheMode="Required"
mc:Ignorable="d">
<Page.Resources>
<MenuFlyout x:Key="DataGridContextMenu">
<MenuFlyoutItem
Click="MenuFlyoutViewDetails_Click"
Icon="OpenFile"
Text="View details" />
</MenuFlyout>
<Style
x:Key="SearchSuggestionItemStyle"
TargetType="ListViewItem"
BasedOn="{StaticResource DefaultListViewItemStyle}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
<DataTemplate
x:Key="SearchSuggestionItemTemplate"
x:DataType="models:Order">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid.Resources>
<Style TargetType="TextBlock"
BasedOn="{StaticResource BodyTextBlockStyle}">
<Setter Property="Margin" Value="8,0,0,0" />
</Style>
</Grid.Resources>
<TextBlock
Grid.Column="0"
Margin="0,0,20,0"
Padding="0"
HorizontalAlignment="Stretch"
Text="{x:Bind InvoiceNumber}" />
<TextBlock
Grid.Column="1"
Margin="0,0,20,0"
HorizontalAlignment="Stretch"
Text="{x:Bind CustomerName}" />
</Grid>
</DataTemplate>
</Page.Resources>
<RelativePanel>
<TextBlock
x:Name="PageTitle"
Style="{StaticResource PageTitleTextBlockStyle}"
Text="Orders" />
<CommandBar
x:Name="MainCommandBar"
HorizontalAlignment="Stretch"
Background="Transparent"
DefaultLabelPosition="Right"
RelativePanel.LeftOf="OrderSearchBox"
RelativePanel.RightOf="PageTitle">
<AppBarButton
x:Name="CommandBarEditButton"
Click="EditButton_Click"
Icon="Edit"
IsEnabled="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedOrder), Mode=OneWay}"
Label="Edit" />
<AppBarButton
x:Name="CommandBarDeleteButton"
Click="DeleteOrder_Click"
Icon="Delete"
IsEnabled="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedOrder), Mode=OneWay}"
Label="Delete" />
<AppBarButton
Click="{x:Bind ViewModel.LoadOrders}"
Icon="Refresh"
Label="Refresh" />
</CommandBar>
<uc:CollapsibleSearchBox
x:Name="OrderSearchBox"
Width="240"
Margin="12,8,12,0"
CollapseWidth="{StaticResource MediumWindowSnapPoint}"
Loaded="OrderSearchBox_Loaded"
RelativePanel.AlignRightWithPanel="True" />
<SplitView
x:Name="ListSplitView"
DisplayMode="Inline"
IsPaneOpen="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedOrder), Mode=OneWay}"
OpenPaneLength="260"
PanePlacement="Right"
PaneBackground="Transparent"
RelativePanel.AlignBottomWithPanel="True"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.Below="PageTitle">
<!-- Displays details about the currently selected order. -->
<SplitView.Pane>
<StackPanel
x:Name="OrderInfoPanel"
Margin="8,8,0,8"
Padding="8,28,0,0"
Background="{ThemeResource LayerFillColorDefaultBrush}"
BorderBrush="{ThemeResource CardStrokeColorDefaultBrush}"
CornerRadius="8,0,0,8"
BorderThickness="1,1,0,1">
<StackPanel.Resources>
<Style TargetType="TextBlock"
BasedOn="{StaticResource BodyTextBlockStyle}">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="TextWrapping" Value="Wrap" />
</Style>
</StackPanel.Resources>
<StackPanel Orientation="Horizontal">
<TextBlock
FontWeight="SemiBold"
Text="Invoice #" />
<TextBlock
FontWeight="SemiBold"
Text="{x:Bind ViewModel.SelectedOrder.InvoiceNumber, Mode=OneWay}" />
</StackPanel>
<TextBlock Text="{x:Bind ViewModel.SelectedOrderGrandTotalFormatted, Mode=OneWay}" />
<StackPanel Margin="0,20,0,20">
<TextBlock
FontWeight="SemiBold"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.SelectedOrder.CustomerName, Mode=OneWay}" />
<TextBlock
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.SelectedCustomer.Phone, Mode=OneWay}" />
<HyperlinkButton
Margin="0,0,0,0"
Padding="0,0,0,0"
Click="EmailButton_Click"
Content="{x:Bind ViewModel.SelectedCustomer.Email, Mode=OneWay}" />
</StackPanel>
<TextBlock FontWeight="SemiBold">Shipping address</TextBlock>
<TextBlock Text="{x:Bind ViewModel.SelectedOrder.Address, Mode=OneWay}" />
<TextBlock
Margin="0,20,0,0"
FontWeight="SemiBold">
Order status
</TextBlock>
<TextBlock Text="{x:Bind ViewModel.SelectedOrder.Status, Mode=OneWay}" />
<TextBlock
Margin="0,20,0,0"
FontWeight="SemiBold">
Payment status
</TextBlock>
<TextBlock Text="{x:Bind ViewModel.SelectedOrder.PaymentStatus, Mode=OneWay}" />
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
<Grid>
<toolkit:DataGrid
BorderThickness="0"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
GridLinesVisibility="None"
IsReadOnly="True"
AutoGenerateColumns="False"
Margin="0,10,0,0"
ItemsSource="{x:Bind ViewModel.Orders, Mode=OneWay}"
SelectedItem="{x:Bind ViewModel.SelectedOrder, Mode=TwoWay}"
SelectionMode="Single"
KeyDown="DataGrid_KeyDown"
Sorting="DataGrid_Sorting"
RightTapped="DataGrid_RightTapped"
DoubleTapped="DataGrid_DoubleTapped"
ContextFlyout="{StaticResource DataGridContextMenu}">
<toolkit:DataGrid.Columns>
<toolkit:DataGridTextColumn
Header="Invoice"
Tag="InvoiceNumber"
Binding="{Binding InvoiceNumber}"/>
<toolkit:DataGridTextColumn
Header="Customer"
Tag="CustomerName"
Binding="{Binding CustomerName}"/>
<toolkit:DataGridTemplateColumn
Header="Date"
Tag="DatePlaced">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="models:Order">
<TextBlock
VerticalAlignment="Center"
Margin="12,0"
Text="{x:Bind sys:String.Format('\{0:d\}', DatePlaced)}"/>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
<toolkit:DataGridTemplateColumn
Header="Total"
Tag="GrandTotal">
<toolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate x:DataType="models:Order">
<TextBlock
VerticalAlignment="Center"
Margin="12,0"
Text="{x:Bind sys:String.Format('\{0:c\}', GrandTotal)}"/>
</DataTemplate>
</toolkit:DataGridTemplateColumn.CellTemplate>
</toolkit:DataGridTemplateColumn>
<toolkit:DataGridTextColumn
Header="Status"
Binding="{Binding Status}"/>
</toolkit:DataGrid.Columns>
</toolkit:DataGrid>
<muxc:ProgressBar
Margin="0,50,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
IsIndeterminate="True"
Visibility="{x:Bind ViewModel.IsLoading, Mode=OneWay}" />
</Grid>
</SplitView.Content>
</SplitView>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource LargeWindowSnapPoint}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ListSplitView.IsPaneOpen" Value="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedOrder), Mode=OneWay}"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource MediumWindowSnapPoint}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ListSplitView.IsPaneOpen" Value="{x:Bind vm:Converters.IsNotNull(ViewModel.SelectedOrder), Mode=OneWay}"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource MinWindowSnapPoint}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="ListSplitView.DisplayMode" Value="Overlay"/>
<Setter Target="OrderInfoPanel.Background" Value="{ThemeResource SystemControlPageBackgroundChromeLowBrush}"/>
<Setter Target="OrderInfoPanel.Margin" Value="8,44,0,8"/>
<Setter Target="MainCommandBar.DefaultLabelPosition" Value="Bottom"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</RelativePanel>
</Page>