WPF C# Webview How to load local html and js files?

-2

In my WPF project when i try to load and render html files i got error 0x80004004 (E_ABORT)) .

My MianWindow.xaml:

<Window x:Class="WpfApp7.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApp7"
    xmlns:WPF="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls.WebView"
    mc:Ignorable="d"
    Title="MainWindow" Height="450" Width="800">
<Grid>
    <WebBrowser x:Name="WebControl" />
</Grid>

and in MainWindow.xaml.cs

public MainWindow()
{
        InitializeComponent();
        WebControl.Navigate(new Uri(@"file:///C:/wwwroot/index.html"));
}

and here is a link where saying that file:/// does not supports by wpf webview and must use NavigateToString or NavigateToLocalStreamUri. But when i render with NavigateToString css styles are not working. How should i declare path to my local files in webview for rendering with css styles and assets?

c#
wpf
webview
asked on Stack Overflow Jan 21, 2020 by lalol • edited Jan 27, 2020 by lalol

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0