WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF wpf wpf

WPF WebBrowser (3.5 SP1) Always on top - other suggestion to display HTML in WPF


If you can't use WebBrowser, your best bet is to probably rewrite your HTML content into a FlowDocument (if you're using static HTML content).

Otherwise, as you mention, you kind of have to special-case WebBrowser, you're right that it doesn't act like a "real" WPF control. You should probably create a ViewModel object that you can bind to that represents the WebBrowser control where you can hide all of the ugly non-binding code in one place, then never open it again :)


Another approach to working round the z-index limitation is to use a popup to overlay your WPF components over the HTMLSee http://karlshifflett.wordpress.com/2009/06/13/wpf-float-buttons-over-web-browser-control/ Note code below is taken straight from the link

<Grid>  <WebBrowser x:Name="wbBrowser" />  <Popup x:Name="puOverlay" AllowsTransparency="True" Placement="Bottom"         PlacementTarget="{Binding ElementName=wbBrowser}">    <Border x:Name="bdrOverLay" CornerRadius="30" BorderBrush="Blue"            Background="#1F000000" Padding="7" BorderThickness="2">      <StackPanel Orientation="Horizontal">        <StackPanel.Resources>          <Style TargetType="{x:Type Button}">            <Setter Property="Width" Value="75" />            <Setter Property="Margin" Value="3.5" />            <Setter Property="VerticalAlignment" Value="Center" />            <Setter Property="HorizontalAlignment" Value="Center" />          </Style>        </StackPanel.Resources>        <Button Command="NavigationCommands.BrowseBack" Content="Back" />        <Button Command="NavigationCommands.BrowseForward" Content="Forward" />        <Button Command="NavigationCommands.BrowseHome" Content="Home" />        <Button Command="ApplicationCommands.Close" Content="Exit" />      </StackPanel>    </Border>  </Popup></Grid>

Alternativly there is a 3rd party control that takes Win32 controls and renders them (as bit maps) into WPF http://www.codeplex.com/WPFWin32Renderer