学习使用Wpf开源的文本编辑器—smithhtmleditor
前言
本文主要介绍使用Wpf文本编辑器——smithhtmleditor。
编辑器使用
首先新建一个项目WpfEditor。
然后到Codeplex下载smithhtmleditor。
下载地址:https://archive.codeplex.com/?p=smithhtmleditor
解压后将SmithHtmlEditor文件夹整个复制。
然后粘贴到我们新建的项目中
然后将该引入SmithHtmlEditor的工程文件。
然后在Com组件中找到Microsoft HTML Object Library,添加引用。
然后编写代码如下:
<Window x:Class="WpfEditor.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:smith="clr-namespace:Smith.WPF.HtmlEditor;assembly=Smith.WPF.HtmlEditor"
xmlns:local="clr-namespace:WpfEditor"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<DockPanel DockPanel.Dock="Top" >
<DockPanel.Resources>
<Style TargetType="{x:Type Label}">
<Setter Property="Padding" Value="0" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Padding" Value="4,2" />
</Style>
</DockPanel.Resources>
<smith:HtmlEditor x:Name="Editor" DockPanel.Dock="Top"/>
</DockPanel>
</Grid>
</Window>
如代码所示,再命名空间中引入了Smith.WPF.HtmlEditor。
xmlns:smith="clr-namespace:Smith.WPF.HtmlEditor;assembly=Smith.WPF.HtmlEditor"
然后使用了Smith.WPF.HtmlEditor程序集下的自定义控件HtmlEditor。
效果图如下:
html格式:
上传图片:
----------------------------------------------------------------------------------------------------
到此,使用Wpf文本编辑器就已经介绍完了。
代码已经传到Github上了,欢迎大家下载。
Github地址: https://github.com/kiba518/WpfEditor
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
注:此文章为原创,任何形式的转载都请联系作者获得授权并注明出处!
若您觉得这篇文章还不错,请点击下方的【推荐】,非常感谢!
https://www.cnblogs.com/kiba/p/15399317.html
最新文章
- html5页面打包成App - Android或Iphone安装程序
- GOLANG 注释
- 地图编辑器V1
- linux下内网端口转发工具:linux版lcx [实现远程内网维护]
- scrollview做定时来回滚动时,总出现错位的情况。
- 转载:C/C++源代码到可执行程序的过程详解
- 如何添加网站for Linux(绑定域名)
- margin系列之keyword auto
- 小技巧,把execl.exe转换成dll
- 2014年10本月微软MVP应用程序启动!
- 前端跨域方案-跨域请求代理(node服务)
- C++/C实现各种排序算法(持续更新)--冒泡排序,选择排序,归并排序
- mvc模式的理解
- Scrapy框架学习第二天
- Kotlin入门(28)Application单例化
- 为什么可逆矩阵又叫“非奇异矩阵(non-singular matrix)”?
- Objective-C 类簇深入理解
- Asp: 解决脚本输出网页出现乱码情况
- CucumberPeople 1.3.2 发布
- [工具]cmd命令大全