这是我声明的依赖属性:
public static void IsDesignModePropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
{
WebBrowser browser = obj as WebBrowser;
if (browser != null)
{
Boolean designMode = (Boolean)args.NewValue;
if (designMode)
{
browser.LoadCompleted += (s, e) =>
{
var htmlDoc = (s as WebBrowser).Document as IHTMLDocument2;
htmlDoc.body.setAttribute("contenteditable", "true");
htmlDoc.designMode = "On";
};
}
else
{
browser.LoadCompleted += (s, e) =>
{
var htmlDoc = (s as WebBrowser).Document as IHTMLDocument2;
htmlDoc.body.setAttribute("contenteditable", "false");
htmlDoc.designMode = "Off";
};
}
}
}
这是我的网络浏览器控件:
<WebBrowser viewmodel:BrowserBehavior.IsDesignMode="True" x:Name="webBrowser1" viewmodel:BrowserBehavior.Html="{Binding SelectedNode.ContentData.FileName, Converter={StaticResource converter}, Mode=OneWay}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="612"/>
我想以编程方式修改网络浏览器的内容,并禁用键盘修改;我的意思是有一个按钮,作用于选择!
这怎么可能?