summaryrefslogtreecommitdiff
path: root/platform/winrt/gsview/MainWindow.xaml
blob: a7f0cce10be1a5b78095c38dfdfd55fe5846d9c0 (plain)
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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<Window x:Class="gsview.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="gsview" Height="800" Width="650">

    <Window.Resources>
        <DataTemplate x:Key="PageTemplate">
            <Image Width="{Binding Width}" Height="{Binding Height}" Stretch="Fill" HorizontalAlignment="Center" Source="{Binding BitMap}" Margin="24,24,0,0">
                <Image.BitmapEffect>
                    <DropShadowBitmapEffect Color="Black" Direction="-50"
                    ShadowDepth="40" Softness=".7" />
                </Image.BitmapEffect>
            </Image>
        </DataTemplate>

        <Style TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter Property="Background" Value="Black" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Customize listview to turn off selection -->
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListViewItem}">
                        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="Selector.IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>

    <!-- To do add in command short cuts and bindings -->
    <DockPanel LastChildFill="True">
        <!-- Menu item at top -->
        <Menu IsMainMenu="True" DockPanel.Dock="Top">
            <MenuItem Header="_File">
                <MenuItem Header="_Open..." Click="OpenFile">
                    <MenuItem.Icon>
                        <Image Source="Resources/OpenFile.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="MuPDF Save As..." >
                    <MenuItem.Icon>
                        <Image Source="Resources/saveHS.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Close" >
                    <MenuItem.Icon>
                        <Image Source="Resources/Close.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Info">
                    <MenuItem.Icon>
                        <Image Source="Resources/info.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Ghostscript Convert..." Click="ConvertClick">
                </MenuItem>
                <MenuItem Header="Extract..." >
                </MenuItem>
                <MenuItem Header="PS to EPS..." >
                </MenuItem>
                <Separator />
                <MenuItem Header="Print...">
                    <MenuItem.Icon>
                        <Image Source="Resources/printer.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Show Messages" Click="ShowGSMessage">
                    <MenuItem.Icon>
                        <Image Source="Resources/Message.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Edit" >
                <MenuItem Header="_Copy" Command="Copy">
                    <MenuItem.Icon>
                        <Image Source="Resources/copy.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator />
                <MenuItem Header="Paste To..." />
                <MenuItem Header="Convert Bitmap" />
                <Separator />
                <MenuItem Header="Add EPS Preview" />
                <MenuItem Header="Extract EPS" />
                <Separator />
                <MenuItem Header="Measure" />
                <MenuItem Header="Convert to vector format..." />
                <MenuItem Header="Text Extract" />
                <MenuItem Header="_Find" Command="Find"/>
                <MenuItem Header="Find Next"/>
            </MenuItem>
            <MenuItem Header="_View">
                <MenuItem Header="Next Page" />
                <MenuItem Header="Previous Page" />
                <MenuItem Header="Goto Page" />
            </MenuItem>
            <MenuItem Header="_Options">
                <MenuItem Header="Ghostscript" />
                <MenuItem Header="Color" />
                <MenuItem Header="Footer Control" IsCheckable="true" Checked="ShowFooter" Unchecked="HideFooter"/>
            </MenuItem>

            <MenuItem Header="_Help" />
        </Menu>
        
        <!-- List of icons for page navigation, print, etc -->
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="WhiteSmoke">
            <Button  Width="20" Height="20" Name="BackPage" Click="OnBackPageClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Left.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Width="20" Height="20" Name="ForwardPage2" Click="OnForwardPageClick" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/Right.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ZoomIn" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/zoom_in.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ZoomOut" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/zoom_out.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ToggleThumbs" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Thumbnails"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/thumbnail.ico"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="ToggleContents" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Contents"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/contents.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="Search" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Search"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/search.png"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="LinksToggle" Background="Transparent" BorderBrush="Transparent">
                <Button.ToolTip>
                    <TextBlock Text="Hyperlinks"/>
                </Button.ToolTip>
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Ellipse>
                                <Ellipse.Fill >
                                    <ImageBrush ImageSource="Resources/hyperlink.png"/>
                                </Ellipse.Fill>
                            </Ellipse>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <Button  Margin="10 0 0 0" Width="20" Height="20" Click="Print" Background="Transparent" BorderBrush="Transparent">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Width="20" Height="20">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="Resources/printer.ico"/>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>
        </StackPanel>

        <!-- The progress bar that runs while the thumbnails are rendered -->
        <Grid x:Name="xaml_ProgressGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_ThumbProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0" 
                     Maximum="100" Height="20" HorizontalAlignment="Stretch" />
            <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Creating Thumbs</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelThumb" Click="CancelLoadClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Height="Auto" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill >
                                    <SolidColorBrush Color="LightSlateGray"></SolidColorBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
                <TextBlock><Bold>Cancel</Bold></TextBlock>
            </Button>
        </Grid>

        <!-- The progress bar that runs during text search -->
        <Grid x:Name="xaml_SearchGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_SearchProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0" 
                     Maximum="100" Height="20" HorizontalAlignment="Stretch" />
            <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Searching</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelSearch" Click="CancelSearchClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Height="Auto" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill >
                                    <SolidColorBrush Color="LightSlateGray"></SolidColorBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
                <TextBlock><Bold>Cancel</Bold></TextBlock>
            </Button>
        </Grid>

        <!-- The progress bar that runs during printing -->
        <Grid x:Name="xaml_PrintGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_PrintProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0" 
                     Maximum="100" Height="20" HorizontalAlignment="Stretch" />
            <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Printing</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelPrint" Click="CancelPrintClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Height="Auto" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill >
                                    <SolidColorBrush Color="LightSlateGray"></SolidColorBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
                <TextBlock><Bold>Cancel</Bold></TextBlock>
            </Button>
        </Grid>

        <!-- The progress bar that runs during distilling -->
        <Grid x:Name="xaml_DistillGrid" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <ProgressBar x:Name="xaml_DistillProgress" Grid.Row="0" Grid.Column="0" Margin="3" Minimum="0" 
                     Maximum="100" Height="20" HorizontalAlignment="Stretch"/>
            <TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="5, 0, 5, 0"><Bold>Distilling</Bold></TextBlock>
            <Button  Grid.Row="0" Grid.Column="2" Width="50" Height="20" Name="xaml_CancelDistill" Click="CancelDistillClick" Background="Transparent" BorderBrush="Transparent" Margin="5,0,5,0">
                <Button.Template>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid>
                            <Rectangle Height="Auto" RadiusX="5" RadiusY="5">
                                <Rectangle.Fill >
                                    <SolidColorBrush Color="LightSlateGray"></SolidColorBrush>
                                </Rectangle.Fill>
                            </Rectangle>
                            <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
                <TextBlock><Bold>Cancel</Bold></TextBlock>
            </Button>
        </Grid>

        <!-- Footer control -->
        <Grid x:Name="xaml_FooterControl" Background="WhiteSmoke" DockPanel.Dock="Bottom" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Margin="5,0,0,0"><Bold>Zoom:</Bold></TextBlock>
            <Slider x:Name="xaml_ZoomSlider" Grid.Row="0" Grid.Column="1" Margin="10, 0, 0, 0" 
                Width="150" Orientation="Horizontal" HorizontalAlignment="Center" 
                Value="100" Minimum="25" Maximum="400" 
                SmallChange="1" LargeChange="1"
                TickPlacement="None" TickFrequency="1"  IsSnapToTickEnabled="True" MouseLeftButtonUp="ZoomReleased"/>
            <TextBox Grid.Row="0"  Grid.Column="2" Width="30" Height="20" VerticalScrollBarVisibility="Hidden" IsReadOnly="True" 
                     HorizontalScrollBarVisibility="Hidden"  TextAlignment="Center" 
                     Text="{Binding Mode=TwoWay, ElementName=xaml_ZoomSlider,Path=Value, UpdateSourceTrigger=PropertyChanged}" />
        </Grid>

        <!-- Thumb viewer/selector -->
        <Grid x:Name="xaml_ThumbGrid" Width="100" Background="DarkGray" DockPanel.Dock="Left" Visibility="Collapsed">
            <ListView x:Name="xaml_ThumbList" HorizontalAlignment="Stretch" 
                      ItemTemplate="{StaticResource PageTemplate}" 
                      ScrollViewer.CanContentScroll="False" 
                      Background="DarkGray" ScrollViewer.PanningMode="Both"
                      PreviewMouseLeftButtonUp="ThumbSelected">
            </ListView>
        </Grid>

        <!-- Contents viewer/selector.  -->
        <Grid x:Name="xaml_ContentGrid" Width="250" Background="DarkGray" DockPanel.Dock="Left" Visibility="Collapsed">
            <ListView x:Name="xaml_ContentList" HorizontalAlignment="Stretch" 
                      ScrollViewer.CanContentScroll="False" PreviewMouseLeftButtonUp="ContentSelected"
                      Background="DarkGray" ScrollViewer.PanningMode="Both">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="5,5,0,0" HorizontalAlignment="Left">
                            <TextBlock TextWrapping="Wrap" Text="{Binding StringMargin}" FontFamily="Segoe UI" FontSize="11" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>

        <!-- Pages are last child fill.  This goes in the center of our dock panel ScrollViewer.CanContentScroll False allows continuous scrolling-->
        <Grid x:Name="xaml_PageGrid" HorizontalAlignment="Stretch" Background="DarkGray" DockPanel.Dock="Left">
            <ListView x:Name="xaml_PageList" HorizontalAlignment="Stretch"
                      ItemTemplate="{StaticResource PageTemplate}" 
                      ScrollViewer.CanContentScroll="False" 
                      Background="DarkGray" ScrollViewer.PanningMode="Both"
                      ScrollViewer.ScrollChanged="ListViewScrollChanged"
                      PreviewMouseLeftButtonUp="PageSelected">
                <!-- This keeps the pages in the center of the panel -->
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </Grid>

    </DockPanel>

</Window>