简体   繁体   English

将xaml / C#中的网页保存到通用应用程序ApplicationData中

[英]Save a webpage in xaml/ C# to ApplicationData, universal app

I am learning C# and xaml, now when isolated storage isn't in windows universal, how can I save a page from the internet and compare it with a previously downloaded page and than view it in the webview? 我正在学习C#和xaml,现在当孤立存储不在Windows通用环境下时,如何保存来自互联网的页面并将其与以前下载的页面进行比较,然后在Webview中查看呢? Here is my attempt: C# code: 这是我的尝试:C#代码:

public sealed partial class OdpadloPage : Page
{

    public OdpadloPage()
    {
        this.InitializeComponent();
        DataContext = this;
        ApplicationView.GetForCurrentView().
                  SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
    }
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    }

}

My xaml code: 我的XAML程式码:

<Grid>
    <Grid.ChildrenTransitions>
        <TransitionCollection>
            <EntranceThemeTransition/>
        </TransitionCollection>
    </Grid.ChildrenTransitions>
    <WebView Margin="10,0,10,10" Source="http://www.gyarab.cz/suplovani/suplov.htm"/>

</Grid>

As you mentioned , IsolatedStorageSettings is not supported at Windows Universal.Instead , you must use ApplicationDataContainer. 如前所述,Windows Universal不支持IsolatedStorageSettings,而必须使用ApplicationDataContainer。

What you have to do is simply call InvokeScriptAsync method of your webview and get the current source code of the page (you can use one-lined javascript code) and save it to the local settings by using ApplicationDataContainer. 您要做的就是简单地调用Webview的InvokeScriptAsync方法并获取页面的当前源代码(可以使用单行javascript代码),然后使用ApplicationDataContainer将其保存到本地设置。

Sorry that I'm not able to provide you some code examples atm. 抱歉,我无法为您提供一些atm代码示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows Universal App中使用C#在XAML中着墨 - Inking in XAML with C# in a Windows Universal App 在通用应用程序中使用C#保存xml文件 - save a xml file with c# in Universal app C#Xaml(Windows Universal App)打开新页面 - C# Xaml (Windows Universal App) open new Page 2对单个C#类的XAML引用(通用App 8.1) - 2 XAML reference to single C# class (Universal App 8.1) WinRT ListView,将itemsource作为列表 <KeyValuePair<string, string> &gt;错误XAML(Windows 8.1通用应用程序(XAML / C#)) - WinRT ListView with itemsource as List<KeyValuePair<string, string>> error XAML (Windows 8.1 Universal App (XAML/C#)) C#XAML Windows通用加载对话框 - C# XAML Windows Universal Loading Dialog XAML到C#函数,通用样式或函数 - xaml to c# function, universal style or function 在通用Windows应用程序中显示便携式灰度图(PGM)图像(c#,XAML) - Displaying Portable Graymap (PGM) images in Universal Windows App (c#, XAML) 客户端发出一些请求后,TCP服务器停止响应[Windows 10 Universal app,C#,XAML] - TCP server stops responding after a few requests from client [Windows 10 Universal app, C#, XAML] 在C#App中保存图像以供ASP.NET网页检索 - Save Image in C# App for retrieval by ASP.NET webpage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM