0

I have a pretty specific problem with the documentviewer control. Let me explain:

I have a documentviewer that is by default in an invisible grid that sits on top of my data-representation. When i press a specific button (generate report, bound to a command on my viewmodel), a report and xps document for the documentviewer(fixed page etc.) is generated and the documentviewer-grid is set to visible. So far so good. The strange thing and the root of my problem is that everything is working fine and displaying as it should when the button is pressed via touch-input on a touch-screen.

When it's pressed via mouse, the command fires, the documentviewer shows, BUT the document shows up all messed up. Tables are a mess, custom-controls are not sized correctly etc. As soon as the cursor is moved into the document or the area inside the documentviewer is clicked, everything lines up and displays correctly.

I suspected a difference between touch and click concerning focus on the control and tried various hacks of manually updating the layout when the control becomes visible. No success.

Additionally: My XPS Document contains a layout with usercontrols and grids that are generated when the generate-report command is fired. What seems interesting is that the user-control scaling seems to break down only when there are multiple elements on the page.

Edit: Changes to visibility have no effect at all. It behaves exactly the same when the documentviewer is visible the whole time and the document it is bound to gets updated.

Any help or ideas appreciated.

  • 2
    Easier to answer if you give us some code that shows your problem. – AndersNS Jan 15 '15 at 12:04
  • Pretty hard to decide what code to show when code is not directly the problem. Document just shows up wrong when button is clicked and not touched. I guess the question could also be, what the hell is the difference between clicking and touching a button that is bound to a command. – Christian Hunziker Jan 15 '15 at 12:08
  • How do you know the code isn't the problem? – Bob. Jan 15 '15 at 12:23
  • Because from the moment when the button is touched/clicked and the command is executed, there is absolutely no difference in code that is executed - but the outcome is not the same. Therefore my question: do touch events somehow differ from click events so that it would explain why in one case the document is shown (probably updated) correctly, and in the other its not. – Christian Hunziker Jan 15 '15 at 12:43

1 Answers1

0

After experimenting for another week, I finally found the solution.

All the problems and incomprehensible layout-magic was caused, because the FixedDocument that was supposed to be displayed was created (and already assigned to the documentviewer), and THEN filled with its content by a worker thread.

The content was displayed, but the layout only updated on mouse-over or click or whatever when the documentviewer received any input. I figure that on input, the documentviewer does another refresh of the assigned document.

So my solution in the end was simple: Create a "work-in-progress" fixed document while adding content, and only assign it to to viewer when everything is done.

What remains now is that content and layout is displayed correctly, but sometimes it takes 5-10 seconds for the content to actually show up. But that's simply a performance issue from loading a heavy document. I'll try to figure out if I can build in some kind of loading notification until the document has fully loaded.