C1FlexViewer is always on top

Posted by: daniel.erdei on 17 January 2022, 1:04 am EST

  • Posted 17 January 2022, 1:04 am EST

    I have a problem using C1FlexViewer in my application. No matter how i define my layout, the C1FlexViewer, more specifically, the area where the PDF document is shown, gets always rendered on top of every other control.

    In the attached image, I have a simple popup that is defined at the end of my MainWindow. The flexviewer is embedded in my XAML before that popup, so usually the popup should get rendered on top, with the the flexviewer behind of it. But as you can see, it's the exact opposite: the flexviewer is on top and my popup is behind of it.

    I have already tried setting the Panel.ZIndex property of the flexviewer, but that does not seem to have any effect. I have also read setting the ZIndex property is not supported at all in this blog post https://www.grapecity.com/forums/wpf-edition/wpf-flexviewerpdfviewer-pr

    How can I ensure, that the flexviewer does not get always rendered on top of every other ui element?

    As our company currently investigates, whether the flexviewer suits our needs and we can buy it, we would need any answer on that as soon as possible. If that did not work at all, that would a KO criterion for us.

    Kind regards,
  • Replied 17 January 2022, 3:24 am EST

    I do have a second question: How can I hide the C1FlexViewer toolbar (the bar above the pdf document itself) in WPF?
  • Replied 17 January 2022, 5:03 pm EST

    Hi Daniel,

    Thanks for the snapshot.

    1. JFYI, FlexViewerPane is not specific to WPF i.e. it is a DxHost Component hosted in WPF. That's why Popup or control will get behind the FlexViewerPane as it doesn't follows the xaml visual tree structure.
    In order to achieve your requirement, you can create your own PopUp window dialog and show over the main window. We have created a sample for you, find the attached sample below.

    2. To hide the MainToolbar, you need to handle Loaded event as : (see code snippet)

    private void FlexViewer_Loaded(object sender, RoutedEventArgs e)
    var flexViewer = (sender as C1FlexViewer);
    var toolBar = flexViewer.Template.FindName("mainToolbar",flexViewer) as MainToolbar;
    toolBar.Visibility = Visibility.Collapsed;

    Please refer the attached sample for the same : FlexViewerDemo.zip

    Best Regards,
  • Replied 17 January 2022, 7:15 pm EST

    Hi Nitin,

    thanks for your quick response.

    Regarding to question 2: After executing the code to hide the mainToolbar in the FlexViewer Loaded event, whenever I change DocumentSource property, I get a NullPointerException. In the attached screenshot you can see, that this Exception is thrown in C1.WPF.FlexViewer.MainToolbar.UpdateSearchButtonEnabled.
    (Note: I have already checked and ensured, that neither the PdfViewer object, nor the DocumentSource object is null)

    It's funny that this just happens in my real application, but not in the demo application you have provided (I can update the document source without any problems in the demo application).

    Can you give my any advice, how I can avoid this NullPointerException? I am using FlexViewer v4.5.2

    Best Regards,
  • Replied 17 January 2022, 8:39 pm EST


    I have a further question: How could I create a custom WPF combobox for the scale/zoom factor, with it's value binded to the FlexViewer ZoomFactor property? I would like to have a combobox with certain items (50%, 100%, 150% ...) and whenever I select any item, the selected value should be applied to the FlexViewer ZoomFactor (via databinding in best-case).

    And same in the other direction: Whenever I change the zoom in the FlexViewer, the Combobox should get updated with the new ZoomFactor value.

    Thanks a lot in advance!

    Kind regards,
  • Replied 18 January 2022, 12:59 am EST


    Thanks for the error snapshot.

    We are unable to replicate the error at our end, Could you please provide some more details that how you are actually using flexviewer and getting this error.

    For ComboBox requirement, You can bind the SelectedValue to the FlexViewer's ZoomFactor property So that you can update FlexViewer's ZoomFactor through ComboBox.
    JFYI, ZoomFactor is of double type and doesn't have fixed listing of ZoomFactors. So it will be difficult to update or add zoomfactors in combobox while updating flexviewer's zoomfactor through mouse.

    Please refer the attached sample for the same: FlexViewerDemo_Mod.zip

  • Replied 19 January 2022, 6:22 pm EST

    Hi Nitin,

    thanks for you response.

    FYI: I had a classical WPF timing problem (at the time when the loaded event handler was executed, not all parts of the pdf viewer were already loaded - thus the NullPointerException).

    I just hide the toolbar using the Dispatcher and DispatcherPriority.Background. This works for now.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels