WPF 通过使用Frame 加载kindeditor文本编辑器
来源:互联网 发布:淘宝天天特价店铺活动 编辑:程序博客网 时间:2024/05/17 23:48
最近在做WPF 客户端发送信息的功能 想要实现发送的信息包含超链接 图片等等,由于以前WEB做过文本编辑器 所以打算通过Frame 加载html页面来实现文本的编辑 然后调用C#代码取得文本编辑器里面的html。
- XAML代码
<Window x:Class="WpfApplication3.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="244*" /> <RowDefinition Height="67*" /> </Grid.RowDefinitions> <Frame x:Name="frame" /> <WrapPanel Grid.Row="1" > <Button Content="html" Width="100" Height="30" Click="Button_Click_1"/> <Button Content="GO" Width="100" Height="30" Click="Button_Click"/> </WrapPanel> </Grid></Window>
2. 后台代码
private void Button_Click(object sender, RoutedEventArgs e) { WebBrowser wb = (WebBrowser)frame.Content; mshtml.HTMLDocumentClass htmldocument = (mshtml.HTMLDocumentClass)wb.Document; string html = wb.InvokeScript("getHtml").ToString(); //调用html页面函数 取得文本编辑器的html } private void Button_Click_1(object sender, RoutedEventArgs e) { this.frame.Source = new Uri(Directory.GetCurrentDirectory() + "/HtmlEdit.html", UriKind.Absolute); }
3.html 页面
<!doctype html><html><head><meta charset="utf-8" /><title>Simple Examples</title><style>form {margin: 0;}textarea {display: block;}</style><link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" /> <script charset="utf-8" src="kindeditor-4.1.10/kindeditor-min.js"></script> <script type="text/javascript"> var editor; KindEditor.ready(function (K) { editor = K.create("textarea[name='content']", { resizeType: 1, allowPreviewEmoticons: false, allowImageUpload: false, items: [ 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline', 'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', '|', 'emoticons', 'image', 'link'] }); }); function getHtml() { return editor.html(); }</script></head><body scroll="no"> <form> <textarea name="content" style="width:700px;height:120px;visibility:hidden;"></textarea> </form></body></html>
通过这样就能实现wpf 使用html页面的文本编辑器
- WPF 通过使用Frame 加载kindeditor文本编辑器
- kindeditor文本编辑器使用
- 使用kindeditor文本编辑器
- KindEditor在线文本编辑器使用
- Html编辑器,富文本编辑器KindEditor使用
- asp.net 文本编辑器kindeditor的使用
- asp.net mvc4 使用KindEditor文本编辑器
- asp.net mvc4 使用KindEditor文本编辑器
- kindeditor富文本编辑器的使用
- 富文本编辑器 kindeditor的使用
- asp.net mvc4 使用KindEditor文本编辑器
- kindeditor富文本编辑器初步使用教程
- KindEditor富文本编辑器的使用
- 24.富文本编辑器Kindeditor的使用
- 配置KindEditor文本编辑器
- kindeditor富文本编辑器
- kindeditor 文本编辑器
- kindeditor文本编辑器
- c实现树的创建和遍历
- ICON
- 事物隔离四种级别演示
- Universal-Image-Loader设置图片大小
- Solr学习总结-Facet
- WPF 通过使用Frame 加载kindeditor文本编辑器
- C#Winform开发经验之Combox键值对
- FORM内置系统函数
- MSMQ 与ESB
- 安全色谱与Web配色技巧
- openfire插件 servlet开发
- solr4.4以上版本安装及安装过程中出现的错误解决方法
- python中的list如何进行相减操作或者将list分片
- leetCode - Sort List