xaml 转换 html,Convert XAML to HTML

Thank you for your reply, but the image still can't be located. Maybe my description is a little bit bad. (or my english :))

Better Description: :)

1. Create a wpf application

2. Add a rich textbox to the application and name it "RichTextbox"

3. Create an "Convert To XAML String" button and insert this source code

Dim XamlString As String

Dim ms As New IO.MemoryStream

Dim xaml As Windows.Markup.XamlDesignerSerializationManager = New Windows.Markup.XamlDesignerSerializationManager(New Xml.XmlTextWriter(ms, System.Text.ASCIIEncoding.UTF8))

xaml.XamlWriterMode = Windows.Markup.XamlWriterMode.Expression

Windows.Markup.XamlWriter.Save(RichTextbox.Document, xaml)

ms.Seek(0, IO.SeekOrigin.Begin)

Dim stReader As IO.StreamReader = New IO.StreamReader(ms)

XamlString = stReader.ReadToEnd

4. Create an "Add Image" button and insert the following source

Dim ofd As New System.Windows.Forms.OpenFileDialog

ofd.Filter = "Image files (*.png;*.gif;*.jpg;*.jpeg)|*.png;*.gif;*.jpg;*.jpeg"

ofd.Multiselect = False

If ofd.ShowDialog = DialogResult.OK Then

Dim img As New Windows.Controls.Image

Dim bitmapImg As New Windows.Media.Imaging.BitmapImage

bitmapImg.BeginInit()

bitmapImg.UriSource = New Uri(ofd.FileName)

bitmapImg.EndInit()

img.Width = bitmapImg.Width

img.Height = bitmapImg.Height

img.Source = bitmapImg

Dim inline As New Windows.Documents.InlineUIContainer

inline.Child = img

If RichTextbox.Selection.Start.Paragraph Is Nothing Then

RichTextbox.Selection.Start.InsertParagraphBreak()

End If

RichTextbox.Selection.Start.Paragraph.Inlines.Add(inline)

End If

5. Run the application and add an image to the richtextbox

6. Drag and Drop the image arround

7. Press the "Convert To XAML String" button

8. Now the String XamlString will contain the following xaml

9. You will see that the image you added is located at ./Image1.bmp

10. Now my problem is to get the stream of the image :)

You can try to run the example you posted and you will see that i won't work.

Also I have to say that it isn't a possibility to create a collection of all added images because if there are many images in the richtextbox and they are moved arround i can't find out which image is which.

Thank you for your help!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值