mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using CefSharp.Example;
|
|
using CefSharp.Wpf.Example.Mvvm;
|
|
|
|
namespace CefSharp.Wpf.Example.Views.Main
|
|
{
|
|
public class MainViewModel : INotifyPropertyChanged
|
|
{
|
|
private string address;
|
|
private IWpfWebBrowser webBrowser;
|
|
private string addressEditable;
|
|
|
|
public string Address
|
|
{
|
|
get { return address; }
|
|
set { PropertyChanged.ChangeAndNotify(ref address, value, () => Address); }
|
|
}
|
|
|
|
public string AddressEditable
|
|
{
|
|
get { return addressEditable; }
|
|
set { PropertyChanged.ChangeAndNotify(ref addressEditable, value, () => AddressEditable); }
|
|
}
|
|
|
|
public IWpfWebBrowser WebBrowser
|
|
{
|
|
get { return webBrowser; }
|
|
set { PropertyChanged.ChangeAndNotify(ref webBrowser, value, () => WebBrowser); }
|
|
}
|
|
|
|
public DelegateCommand GoCommand { get; set; }
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public MainViewModel()
|
|
{
|
|
Address = ExamplePresenter.DefaultUrl;
|
|
AddressEditable = ExamplePresenter.DefaultUrl;
|
|
|
|
GoCommand = new DelegateCommand(Go, () => !String.IsNullOrWhiteSpace(Address));
|
|
|
|
PropertyChanged += OnPropertyChanged;
|
|
}
|
|
|
|
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName == "Address")
|
|
{
|
|
AddressEditable = Address;
|
|
}
|
|
}
|
|
|
|
private void Go()
|
|
{
|
|
Address = AddressEditable;
|
|
}
|
|
}
|
|
}
|