Hi
I'm trying to using RadBook control to display a PDF file and also a custom control named DrawingCanvas to draw some shapes over the PDF file loaded.
I've done this successfully thanks to the vast amount of samples available.
Here is how I do:
I load the file as follows:
private void LoadFile(String filePath)
{
documentStream = new FileStream(filePath, FileMode.Open);
var doc = new PdfFormatProvider(documentStream, FormatProviderSettings.ReadOnDemand).Import();
book.ItemsSource = doc.Pages;
}
And here is the DataTemplate which I use:
<DataTemplate x:Key="PageTemplate">
<Viewbox>
<Grid>
<ui:FixedDocumentSinglePagePresenter Page="{Binding}" Width="500" Height="500"/>
<hosts:DrawingCanvas Width="500" Height="500" Margin="15" Background="#00000000" />
</Grid>
</Viewbox>
</DataTemplate>
And everything works great.
My problem is that, when the page is changed (on PageChanged event), I want to access the DrawingCanvas!
I tries the 2 approaches mentioned in this post
How to access controls in RadBook DataTemplete?, but it doesn't help me.
When using the loaded event, I have 2 problems:
- When paging back, the events (sometimes) does not raise!
- It seems the RadBook caches the pages, so while RightPageIndex is 0, I get events of canvases in page 1 and 2.
And when trying to use the RadBook.ItemContainerGenerator the problem is that myBook.ItemContainerGenerator.ContainerFromIndex(leftPageInd) returns null,
and I also tried to use the book.Items property, but my Items type are RadFixedPage (because I've set ItemsSource of book to PdfFormatProvider's Pages property) and I don't know how can I use it to get my DrawingCanvas.
Regards, Vahid