xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:a="clr-namespace:System.Windows.Annotations;assembly=PresentationFramework"
Title="Flow Document Reader + Annotations"
x:Class="Window1" Initialized="OnInitialized" Closed="OnClosed">
CommandTarget="{Binding ElementName=reader}">Create Text Note
Chapter 1
Why WPF?
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is a test
this is another test
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
//File:Window.xaml.vb
Imports System
Imports System.IO
Imports System.Windows
Imports System.Windows.Annotations
Imports System.Windows.Annotations.Storage
Public Partial Class Window1
Inherits Window
Private stream As Stream
Public Sub New()
InitializeComponent()
End Sub
Protected Overloads Sub OnInitialized(sender As Object, e As EventArgs)
Dim service As AnnotationService = AnnotationService.GetService(reader)
If service Is Nothing Then
stream = New FileStream("storage.xml", FileMode.OpenOrCreate)
service = New AnnotationService(reader)
Dim store As AnnotationStore = New XmlStreamStore(stream)
service.Enable(store)
End If
End Sub
Protected Overloads Sub OnClosed(sender As Object, e As EventArgs)
Dim service As AnnotationService = AnnotationService.GetService(reader)
If service IsNot Nothing AndAlso service.IsEnabled Then
service.Store.Flush()
service.Disable()
stream.Close()
End If
End Sub
End Class