KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to open HTML file in WebBrowser window of WPF using MVVM patten. Note: I have fixed the issues i was getting. Now this code works as desired. ViewHTMLPageView.xaml <Window x:Class="MyProject.ViewHTMLPageView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyProject.Utility" Title="HTML Report" Height="454" Width="787" > <Grid Name="grid1"> <WebBrowser local:WebBrowserUtility.BindableSource="{Binding ReportPage}" /> </Grid> </Window> ViewHTMLPageViewModel.cs namespace MyProject { public class ViewHTMLPageViewModel: ViewModelBase { public ViewHTMLPageView() { //Testing html page on load _reportPage = "<table border='5'><tr><td> This is sample <b> bold </b></td></tr></table>"; OnPropertyChanged("ReportPage"); } private string _reportPage; public string ReportPage { get { return _reportPage; } set { if (_reportPage != value) { _reportPage = value; OnPropertyChanged("ReportPage"); } } } } WebBrowserUtility.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Controls; using System.Windows; namespace MyProject.Utility { public static class WebBrowserUtility { public static readonly DependencyProperty BindableSourceProperty = DependencyProperty.RegisterAttached("BindableSource", typeof(string), typeof(WebBrowserUtility), new UIPropertyMetadata(null, BindableSourcePropertyChanged)); public
Tags (comma-separated)
Save Edits
Cancel