create a AnnotationToolbar with pdfnet in windows 8.1

95 Views Asked by At

Im trying to create a AnnotationToolbar with pdfnet in a windows 8.1 project.

In my page xaml i have this

    xmlns:toolControls="using:pdftron.PDF.Tools.Controls"
...
    <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="53" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <toolControls:AnnotationToolbar x:Name="anBar"  Height="53"></toolControls:AnnotationToolbar>
        <Border Grid.Row="1" x:Name="PDFViewCtrlBorder" Child="{Binding PDFViewCtrl}"/>
        </Grid>

and in my code behind i have this

public ToolManager _ToolManager;
pdftron.PDFNet.Initialize();
            _ViewModel = new ViewModels.MainPageViewModel();
            this.DataContext = _ViewModel;
    _ToolManager = new ToolManager(_ViewModel.PDFViewCtrl);
                anBar = new pdftron.PDF.Tools.Controls.AnnotationToolbar(_ToolManager);

The annotation bar is displayed but when i press any of the options i get a exception inside the AnnotationToolbarViewModel saying the ToolManager is null.

Whats the correct way of creating a AnnotationToolbar ?

1

There are 1 best solutions below

0
On

This happens because anBar is just a variable name pointing to a thing in the UI tree. Setting anBar to a new variable doesn't actually change what is in the UI tree. Instead, you could try to call anBar.ToolManager = _ToolManager;