public partial class MainPage : UserControl
{
private const string DocumentPath = "CageManagementFeatures.docx";
private RadDocumentBindingSource bindingSource = new RadDocumentBindingSource();
private DocumentViewManager viewManager;
public MainPage()
{
InitializeComponent();
this.viewManager = (DocumentViewManager)this.Resources["viewManager"];
}
private void LoadDocument(Stream stream, string extension)
{
RadDocument doc;
IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);
if (provider != null)
{
doc = provider.Import(stream);
}
else
{
MessageBox.Show("Unknown format.");
return;
}
doc.Measure(RadDocument.MAX_DOCUMENT_SIZE);
doc.Arrange(new RectangleF(PointF.Empty, doc.DesiredSize));
doc.LayoutMode = DocumentLayoutMode.Paged;
doc.DefaultPageLayoutSettings.Width = 320 / 0.7F;
doc.DefaultPageLayoutSettings.Height = 390 / 0.7F;
doc.SectionDefaultPageMargin = new Padding(55);
doc.Sections.First.PageMargin = new Padding(55);
doc.UpdateLayout();
this.book.RightPageIndex = 0;
this.viewManager.Document = doc;
bindingSource.Document = doc;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
<!-- NULL ERROR OCCURS IN THIS LINE-->
using (Stream stream = Application.GetResourceStream(this.GetResourceUri(DocumentPath)).Stream)
{
this.LoadDocument(stream, ".docx");
}
this.book.ItemsSource = bindingSource;
}
private Uri GetResourceUri(string resource)
{
AssemblyName assemblyName = new AssemblyName(this.GetType().Assembly.FullName);
string resourcePath = "/" + assemblyName.Name + ";component/" + resource;
Uri resourceUri = new Uri(resourcePath, UriKind.Relative);
return resourceUri;
}
private void Simulation_Click(object sender, RoutedEventArgs e)
{
book.Visibility = Visibility.Collapsed;
radMediaPlayer1.Visibility = Visibility.Visible;
radMediaPlayer1.Play();
}
}
}
1. Why am I getting a Null Value when stepping through the code shows a
value in the GetResourceUri return value?
2. I have the document in a folder "Documents/Cage Management Features.docx"
which didn't work and so I placed it in the root folder and removed spaces,
but that didn't work either.
3. The mainpage.xaml is copied from the sample.
Any suggestions would be appreciated. Thank you.
I want to use the rich digital media experience book to make a flipping book
I need to put a pdf viewer inside page and bind it to a pdf path.
The pdf file exist on the server at the website not at the silverlight application
what is the xaml and c# code that do this ?
<
telerik:RadBook
Grid.Row
=
"0"
x:Name
=
"book"
ItemsSource
=
"{Binding DagboekNotities}"
LeftPageTemplate
=
"{StaticResource LeftPageTemplate}"
RightPageTemplate
=
"{StaticResource RightPageTemplate}"
FirstPagePosition
=
"Left"
IsKeyboardNavigationEnabled
=
"True"
Margin
=
"2"
/>
Private _dagboekNotities As New ObservableCollection(Of DagboekNotitieVoorsteller)
Public Property DagboekNotities() As ObservableCollection(Of DagboekNotitieVoorsteller)
Get
Return _dagboekNotities
End Get
Set(ByVal value As ObservableCollection(Of DagboekNotitieVoorsteller))
_dagboekNotities = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("DagboekNotities"))
End Set
End Property