I need to embed a standard webapp inside a windows app container.
The container just needs to be a wrapper around a webkit or similar rendering engine (I would like to avoid using IE rendering engine if possible) and it would contain some minimal window management logic - things like being borderless with no titlebars, being able to fix position and size, and custom overlay/always-on-top rules based on currently focused window.
I've been looking at node-webkit and it seems to fit the bill as far as containing a webapp is concerned, but I'm not sure I would be able to do the latter.
Can this be done with node-webkit, is there some other approach that would fit my use case better? I have absolutely no idea how windows app development is done, so I would appreciate some help.
答案 0 :(得分:2)
如果您使用的是WPF,则可以使用以下内容创建窗口(xaml):
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None"
Title="MainWindow" Left="100" Top="200" Height="350" Width="525" PreviewKeyDown="Window_PreviewKeyDown">
<Grid x:Name="grdBrowserHost">
</Grid>
</Window>
WindowStyle
attr None
表示&#34;无边界,没有标题栏&#34;窗口。 Left
和Top
用于排名,Width
和Height
不言自明。所有这些属性都可以通过代码隐藏使用简单的this.Width
等来访问... PreviewKeyDown
我放在这里因为在这个例子中(正如您将看到的),Topmost
属性将被更改来自代码(动态)。
代码隐藏应该看起来像 使用System;
using System.Windows;
using System.Windows.Input;
namespace WpfApplication2
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
System.Windows.Controls.WebBrowser browser = new System.Windows.Controls.WebBrowser();
// you can put any other uri here, or better make browser field and navigate to desired uri on some event
browser.Navigate(new Uri("http://www.blic.rs/"));
grdBrowserHost.Children.Add(browser);
}
private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.Close();
}
else
{
this.Topmost = !this.Topmost;
}
}
}
}
在这个例子中,我创建了默认的WebBrowser
控件来显示html。如果您想要其他一些Web渲染引擎,您必须找到第三方控件并将其包含在您的引用中。对于webkit
,您可以查看How to use WebKit browser control in WPF
答案 1 :(得分:0)
您需要的是&#34; UWP Bridge for web apps&#34; ; - )
查看Windows开发人员中心: UWP Bridge for web apps - Create your app now