您的位置:首页 > Web前端 > HTML

学习使用Wpf开源的文本编辑器—smithhtmleditor

2021-10-12 19:58 826 查看

前言

本文主要介绍使用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.R
56c
esources>
<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

 

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: