or
public
class
DataRow
{
public
int
X {
get
;
set
; }
public
int
Y {
get
;
set
; }
public
bool
Exclude;
}
ObservableCollection<DataRow> SeriesSource =
new
ObservableCollection<DataRow>();
SeriesMapping series =
new
SeriesMapping();
series.ItemsSource = source;
series.ItemMappings.Add(
new
ItemMapping(
"X"
, DataPointMember.XValue));
series.ItemMappings.Add(
new
ItemMapping(
"Y"
, DataPointMember.YValue));
<
Window
x:Class
=
"TelerikPDFViewerTest.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"550"
Width
=
"525"
>
<
Window.CommandBindings
>
<
CommandBinding
Command
=
"Open"
CanExecute
=
"Open_CanExecute"
Executed
=
"Open_Executed"
/>
<
CommandBinding
Command
=
"Close"
CanExecute
=
"Close_CanExecute"
Executed
=
"Close_Executed"
/>
</
Window.CommandBindings
>
<
Grid
>
<
telerik:RadPdfViewer
Name
=
"pdfViewer"
Margin
=
"3,30,3,3"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
/>
<
telerik:RadButton
Name
=
"btnOpen"
Content
=
"Open"
Margin
=
"3,3,0,0"
VerticalAlignment
=
"Top"
HorizontalAlignment
=
"Left"
Width
=
"72"
Command
=
"Open"
/>
<
telerik:RadButton
Name
=
"btnClose"
Content
=
"Close"
Margin
=
"0,3,0,3"
VerticalAlignment
=
"Top"
HorizontalAlignment
=
"Right"
Width
=
"72"
Command
=
"Close"
/>
</
Grid
>
</
Window
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
namespace
TelerikPDFViewerTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
private
System.IO.FileStream fs =
null
;
public
MainWindow()
{
InitializeComponent();
}
private
void
Open_CanExecute(
object
sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute =(System.IO.File.Exists(
"benchbook.pdf"
));
e.Handled =
true
;
}
private
void
Open_Executed(
object
sender, ExecutedRoutedEventArgs e)
{
fs =
new
System.IO.FileStream(
"benchbook.pdf"
, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Delete);
pdfViewer.DocumentSource =
new
Telerik.Windows.Documents.Fixed.PdfDocumentSource(fs);
}
private
void
Close_CanExecute(
object
sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = (
this
.pdfViewer.Document !=
null
);
e.Handled =
true
;
}
private
void
Close_Executed(
object
sender, ExecutedRoutedEventArgs e)
{
this
.fs.Close();
//Get NullReferenceException in both cases
//First try to set document source = null
this
.pdfViewer.DocumentSource =
null
;
//Or try just releasing the document
//this.pdfViewer.Document = null;
}
}
}