I attached a screenshot to show what I mean. Basically when I try to show any html page in the xamwebhtmlviewer, even though the control is inside a canvas on a child window, the actual html shows up outside the window. When I move the mouse to the top of the child window, the html suddenly snaps back inside the child window. Here is the xaml. In the codebehind all I do is set the SourceURI property.
<controls:ChildWindow x:Class="Comdata.PdfViewer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" Width="824" Height="824" Title="PdfViewer" xmlns:ig="http://infragistics.com/Controls"> <Canvas Name="panMain"> <Button x:Name="OKButton" Content="OK" Width="75" Height="23" HorizontalAlignment="Right" Canvas.Left="731" Canvas.Top="0" /> <ig:XamWebHtmlViewer Canvas.Left="0" Canvas.Top="29" Name="htmlView" Width="806" Height="760" /> </Canvas></controls:ChildWindow>
This turns out to be a pretty nice solution for displaying a PDF in a child window
I was able to get this working sort of with the following event handling code:
I used the following method to setup and event for when the window is moved:
http://forums.silverlight.net/forums/p/113198/255239.aspx
Added the following code to the new MouseLeftButtonUp event and the Gotfocus event
xamHtmlViewer1.VerticalContentAlignment =
VerticalAlignment.Stretch;
xamHtmlViewer1.Visibility =
Visibility.Collapsed;
Visibility.Visible;
This seemed to take care of the refresh on the initial load and on the window move.
I have tried both the ChildWindow and the XamDialogWindow. The XamDialogWindow does not handle the modal concept consistently and has refresh issues as well.
The ChildWindow works much better. Is there a way to force the LayoutUpdated event? I would prefer to stay with the ChildWindow solution.
Hello,
The XamHtmlViewer control listens for the LayoutUpdated event of the container control (ChildWindow in your case) in order to reposition itself. The ChildWindow control doesn't behave like the other layout controls - Grid and StackPanel, it doesn't fire LayoutUpdated to its children. When you move your mouse to the top of the ChildWindow , LayoutUpdated event is fired and the XamHtmlViewer is updated.
Instead using the ChildWindow you can use our XamDialogWindow, which was designed to work with our XamHtmlViewer.
Regards,
Doychin Dochev