前言
本文主要介紹使用Wpf文本編輯器——smithhtmleditor,
編輯器使用
首先新建一個專案WpfEditor,
然后到Codeplex下載smithhtmleditor,
下載地址:https://archive.codeplex.com/?p=smithhtmleditor

解壓后將SmithHtmlEditor檔案夾整個復制,

然后粘貼到我們新建的專案中

然后將該引入SmithHtmlEditor的工程檔案,

然后在Com組件中找到Microsoft HTML Object Library,添加參考,

然后撰寫代碼如下:
<Window x:
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="https://www.cnblogs.com/kiba/p/0" />
<Setter Property="VerticalAlignment" Value="https://www.cnblogs.com/kiba/p/Center" />
<Setter Property="VerticalContentAlignment" Value="https://www.cnblogs.com/kiba/p/Center" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Padding" Value="https://www.cnblogs.com/kiba/p/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

https://www.cnblogs.com/kiba/
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/310326.html
標籤:C#
上一篇:如何從HTTP請求讀取的excel檔案中創建一個pandasDataFrame?
下一篇:CentOS安裝新版Git
