.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

why DataFormats.XamlPackage does not preserves tag

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :WPF


i need to pass some data from a flow document to another one

but if i use the following code the Tags are  eliminated!

is there a way to prevent this?







Dim tr As New TextRange(LD.ContentStart, (LD.ContentEnd))

tr.Save(ms, DataFormats.XamlPackage)

ms.Position = 0


Dim tr3 As

View Complete Post

More Related Resource Links

Problem when Append DataFormats.xamlPackage RichTextBox

public partial class Window12 : Window { public Window12() { InitializeComponent(); } FileStream fStream; private void btnClick_Click(object sender, RoutedEventArgs e) { TextRange ran = new TextRange(txtMsg.Document.ContentStart, txtMsg.Document.ContentEnd); ran.Save(fStream, DataFormats.XamlPackage); txtMsg.Document.Blocks.Clear(); txtMsg.Focus(); } private void Window_Loaded(object sender, RoutedEventArgs e) { string fileName = @"D:\\part1.xaml"; if (File.Exists(fileName)) fStream = new FileStream(fileName, FileMode.Append, FileAccess.Write); else fStream = new FileStream(fileName, FileMode.Create); txtMsg.Focus(); } private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { fStream.Close(); } } Hi, I have WPF RichTextbox and a button When I insert the text or Image and Click the button the text will save in D: drive with DataFormats.XamlPackage Initially it works fine, when I try to append the text (Close window and open again then insert the text )It gives the error in range.Save(fStream,DataFormats.XamlPackage); Error Message:Cannot open package because FileMode or FileAccess value is not valid for the stream.am

Issue with persisting from MemoryStream in XamlPackage format


I am trying to persist some data from a rich text box to a BLOB in a database

		void TestCode2()
			TextRange range = new TextRange(this.richTextBox1.Document.ContentStart, this.richTextBox1.Document.ContentEnd);

			MemoryStream mem = new MemoryStream();

			range.Save(mem, System.Windows.DataFormats.XamlPackage);

			byte[] persist = mem.GetBuffer();

			MemoryStream mem2 = new MemoryStream(persist);
				range.Load(mem2, System.Windows.DataFormats.XamlPackage);
			catch (ArgumentException ex)
				System.Diagnostics.Debug.WriteLine(string.Format("Exception {0}", ex.Message));

The code above summarizes what I am trying to do.

But the main problem is an ArgumentException is being thrown.

But if do the following everything works OK:

		void TestCode()
			TextRange range = 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend