Awesomium Webcontrol not loading any web page within WPF Page frame control - wpf

I have added Awesomium webcontrol in my WPF Page (Frame Navigation)
But its not loading any webcontent, but if i add the webcontrol in WPF Window, its working fine.
Please suggest me how to load a Awesomium webcontrol within WPF Page control
Below is the code which i am using in my application
Thanks in advance.
<Page x:Class="Project15A.SocialMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:Project15A"
xmlns:my1="clr-namespace:Project15A.Controls"
xmlns:my2="http://schemas.awesomium.com/winfx"
MinHeight="300" MinWidth="500" Title="Project15A"
Loaded="Window1_Loaded">
<Grid Background="White">
<my2:WebControl HorizontalAlignment="Left" Margin="154,65,0,0"
Name="webControl1" VerticalAlignment="Top"
Source="http://www.google.com" />
</Grid>
</Page>

So I figured this one out. It is not a bug in Awesomium. (Though I think it should be on a quick start page.)
Awesomium supports two view modes. Offscreen and Windowed.
Offscreen is something that very manual. All input goes through you. (Why the default events don't still fire is kind of odd). I think this is the mode you will end up using if you want to interact with your HTML.
But if you want a normal imbedded browser window then you need to turn on the Window view mode.
Here is an example:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:awe="http://schemas.awesomium.com/winfx"
x:Class="WpfAndSpa.MainWindow">
<Grid>
<awe:WebControl x:Name="WebControl"
ViewType="Window" <--------------+
Source="http://google.com"/> |
</Grid> |
</Window> |
|
This is the key part -----------------------------------------+

Related

MahApps.Metro 0.13.1: Show window commands without display the titlebar

I am developing an application in WPF using MahApps.Metro 0.12.1. In this application I don't show the titlebar, staying visible minimize, maximize and close commands. Below I show the code:
<controls:MetroWindow xmlns:views="clr-namespace:View.Views"
xmlns:titleBar="clr-namespace:View.Views.TitleBar"
x:Class="View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
GlowBrush="{DynamicResource AccentColorBrush}"
ShowWindowCommandsOnTop="False"
ShowTitleBar="False"
Title="MainWindow" Height="400" Width="600"
AllowsTransparency="False">
<Grid>
...
</Grid>
The problem arises when I upgrade to the version 0.13.1 of MathApps.Metro, where these commands are not displayed, forcing me to re-establish the titlebar to display the commands again ShowTitleBar="True" and this is what I do not want: display the titlebar.
I was looking at the release notes of MathApps.Metro 0.13.1 and reports that changes were made to the section of the titlebar​​, but no further details are given.
My questions are: Is there a simple way to display the minimize, maximize and close commands without showing the title bar? What is the best way to do this?
thanks
you can put the window buttons directly in your main window like this
<Grid>
<!-- the window button commands -->
<Controls:WindowButtonCommands Panel.ZIndex="1"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:MetroWindow}}}" />
...
</Grid>
hope that helps
Is there a simple way to display the minimize, maximize and close commands without showing the title bar? What is the best way to do this?
Actually not very simple, but possible. Basically you need to create your own Style template and override the ContentPresenter for your window to do so.
You may take a look at this question.
Besides that, this post will guide you through the process of designing your own titlebar.

click on hyperlink (navigateuri) in one view should open another view in WPF MVVM

I am working on a WPF project which implements the MVVM architecture. I have a requirement where, a click on a hyperlink in one view(ux){Usercontrol} should open another view(window). I am able to load a view(usercontrol) through another view(window) by simply mentioning namespace:UsercontrolViewName in the host view, but I am clueless about how to do it through a hyperlink.
<UserControl x:Class="CCSAdvantage.AddOn.UX.DisplayPhoneNumbersView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:res="clr-namespace:CCSAdvantage.AddOn.UX.Internationalization"
xmlns:local="clr-namespace:CCSAdvantage.AddOn.UX"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d>
<Grid>
<TextBlock Grid.Row="0">
<HyperlinkNavigateUri="">AdditionalPhone(s)/Manage</Hyperlink>
</TextBlock>
</Grid>
</UserControl>
This is the code for my UserControl, the Grid has other elements but I eliminated the details for simplicity. Additional Phone(s)/Manage => On clicking this link, a new window view which is also in xaml should open up. I tried giving the Window views name in the navigateuri property, but it does not work
Any help is appreciated. Thanks!
My problem was accessing the another view(v2) from the current view(v1), I am in. This can be achieved by using a delegate which is called at runtime in the v1's viewmodel, which calls window loader function in V2, this would load the window view(v2)
Check this Hyperlink in WPF Application.

MainWindow loaded but not visible at all time

I want to build a WPF Application that, when started, only has a tray Icon. If the User interacts with Menu Entries from the Tray's Context Menu, there will be Windows.
I need to load the MainWindow though, so I can listen to Clipboard Changed Events. But I don't want to show it.
I tried:
<Window x:Class="ClipboardListener.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Title="Should not see me"
ShowInTaskbar="False" Visibility="Collapsed" Opacity="100"
Width="320" Height="240">
But it still shows up? Setting Visibility to Hidden does not work for me since I need some Window to register the Clipboard Event Listener with the WinAPI.
Any Ideas?
I've recently had very similar task. All my attempts to make Window invisible, my googling, my stackoverflowing etc. failed. Finally I had a feeling that invisible window is something that should not be in WPF on some reason. It would be an easy task if there was TrayIcon control like in WinForms. Unfortunately, WPF does not have TrayIcon. This leads to the one that is present in WinForms.
Here's a good article on the issue. And my code that uses this dll:
<Window x:Class="ScannerClientWpf.TrayIcon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ni="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
Title="TrayIcon" WindowStyle="None" AllowsTransparency="True" Background="Transparent" ShowActivated="False" ShowInTaskbar="False" >
<Grid>
<ni:TaskbarIcon IconSource="/ScannerClient;component/app.ico"
ToolTipText="ScannerClient">
<ni:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="Close" Click="MenuItem_Click"/>
</ContextMenu>
</ni:TaskbarIcon.ContextMenu>
</ni:TaskbarIcon>
</Grid>

How do I embed one WPF form into another?

I would like to have master WPF form with tab control where each tab contains one independent WPF form. Those forms do not depend on each other, so I thought it will be easier to develop each of them separately and then just embed them into master form.
Number of forms is known, so there is no need for dynamic plugin system.
When you use a Frame or NavigationWindow you can have it load different xaml Pages and even html. You can also make it act like a browser with forward and backward navigation. See http://msdn.microsoft.com/en-us/library/ms750478.aspx
You could put a Frame on each tab and have it load a certain Page.
<Window x:Class="PluginApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<DockPanel>
<Frame Name="frame" NavigationUIVisibility="Visible" Source="SomePage.xaml" />
</DockPanel>
</Window>
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowTitle="Page Title"
WindowWidth="500"
WindowHeight="200">
Hello world
</Page>
Make the child forms derive from UserControl, in the master form add a tab control with one of those user controls inside each tab.
I prefer make this with userControl
First create User control
after, include reference of this userControle in another place
anywhere in the frmHome...
<DockPanel>
<Entity:ucContactList/>
</DockPanel>

WPF 3.5 WebBrowser control and ZIndex

I'm trying to figure out why the control does not honor ZIndex.
Example 1 - which works fine
<Canvas>
<Rectangle Canvas.ZIndex="1" Height="400" Width="600" Fill="Yellow"/>
<Rectangle Canvas.ZIndex="2" Height="100" Width="100" Fill="Red"/>
</Canvas>
Example 2 - which does not work
<Canvas>
<WebBrowser Canvas.ZIndex="1" Height="400" Width="600" Source="http://www.stackoverflow.com"/>
<Rectangle Canvas.ZIndex="2" Height="100" Width="100" Fill="Red"/>
</Canvas>
Thanks,
-- Ed
Unfortunately this is because the WebBrowser control is a wrapper around the Internet Explorer COM control. This means that it gets its own HWND and does not allow WPF to draw anything over it. It has the same restrictions as hosting any other Win32 or WinForms control in WPF.
MSDN has more information about WPF/Win32 interop.
You are running into a common WPF pitfall, most commonly called the "The Airspace Problem". A possible solution is to NOT use the WebBrowser control, and instead go for something a little crazier - namely an embedded WebKit browser rendering directly to WPF. There are two packages that do this; Awesomonium (commercial) and Berkelium (open-source). There's a .NET wrapper for both of these.
You could SetWindowRgn to fake the overlapping area by hiding it as shown here:
flounder.com
msdn
I solved a similar issue where I was hosting a 3rd party WinForms control in my WPF application. I created a WPF control that renders the WinForms control in memory and then paints it to a bitmap. Then I use DrawImage in the OnRender method to draw the rendered content. Finally I routed mouse events from my control to the hosted control. In the case of a web browser you would also have to route keyboard events.
My case was fairly easy - a chart with some simple mouse interaction. A web browser control may have other issues that I didn't take into consideration. Anyway I hope that helps.
I hit this issue as well. In my case I was dragging images from one panel into the WebBrowser, but of course as soon as my image moved into the browser it was hidden.
Currently working on the following solution:
When the Image drag starts, create a Bitmap of the WebBrowser using "RenderTargetBitmap"
Add your Bitmap to the canvas, using the same width/location as the webbrowser
webControl.Visibility = Visibility.Hidden.
When the drag is released, remove your bitmap and set webControl.Visibility = Visible.
This solution is very specific to my situation, but maybe it will give you some ideas.
I managed to solve this by using this structure, check out the properties configuration in each element:
<Canvas ClipToBounds="False">
<Popup AllowsTransparency="True" ClipToBounds="False" IsOpen="True">
<Expander>
<Grid x:Name="YourContent"/>
</Expander>
<Popup>
</Canvas>
You just have to manage the Expander to show or hide your content, I'm using it for a menu bar, I think that the expander is optional depending on the case.
Check out this picture with the result, you can even show your controls on top of the WebBrowser and even outside the main window:

Resources