WPF - RichTextEditor - wpf

im searching for a Usercontrol that generates XAML-Code (Flowdocument Code)
For a Bold Text -> <Paragraph><Bold>Text</Bold></Paragraph>

You may want to have a look at the RichTextBox in the Extended WPF Toolkit - http://wpftoolkit.codeplex.com/wikipage?title=RichTextBox
I haven't tried it, but according to the documentation it has a XamlFormatter as well.

From what kind of object do you want to generate the Xaml-code?
If it is a TextBox content you could try to use some Converter classes.

Related

Simple XAML viewer in WPF

I need to write XAML of a WPF control to string. I used XamlWriter.Save(). It works good. Also I need to format, indent and show the string in a editor (read only) like VS Xaml code view. I dont know how to do this.
Please share your valuable ideas.
You can save to a XmlWriter instance, create a XmlWriter, create a XmlWriterSettings instance and set the Indent property to true and set this on your XmlWriter. That way you should have the indentation.
Now for a control to display it, you could use the RichTextBox in wpf, or look for a custom control around the web.

Is WPF's FlowDocument content user-editable?

I understand and have read about using WPF's FlowDocument to create an XML style document on screen, but is the content presented editable by the user, or is it read only? And, if so, how is this done?
My question mostly centres around the use of the listitem control because it would be nice to be able to edit the order of the list items presented for use in my program, rather than me having to create my own custom control(s).
Regards.
FlowDocuments as objects are editable, if they can be edited in the UI depends on the controls that use them. If you use them in a Page they are not, if you use them in a RichTextBox they are.

Can I create equivalent of C# attribute or metadata for WPF child controls in XAML code?

Can I add some kind of custom attributes in XAML ?
Perhaps you mean Attached properties (scroll down for info on how to create a custom one)? For examle "DockPanel.Dock" is an Attached property.
Or maybe Markup extensions? (though that is something a little bit different)
You can also place Attributes on custom controls and read them in code behind - just like any other .NET class, but that is not possible to do from XAML (since those are set per-type/method/..., not per-instance).
You can, using Attatched Properties. This lets you add your own and data to the xaml on any control you choose.

Blend Slider Control

Is there a free implementation of the text box in Blend's property grid that allows you to change the number by clicking and dragging? Or perhaps another way to ask is what kind of control called so I can google it?
just try this
http://www.codeproject.com/KB/WPF/MicrosoftBlendStyleTextBo.aspx
It's called a numeric UpDown control. (Terrible name, I know).
MS has a sample implementation for WPF, although I think you'll have to provide the draggable part yourself.

What is the best substitute for FlowDocument in Silverlight?

I'm porting an application from WPF to Silverlight and was saddened to read of the lack of FlowDocument support.
What is the best way in Silverlight then to display text with markup?
I just need the basics, e.g.
bold
italic
hyperlink
colors
font sizes
Added:
I don't mean a RichTextBox (as in the Vectorlight demo) but a way to format text on the application surface itself, like I can do with FlowDocument in WPF:
(source: deviantsart.com)
In Silverlight 3 Vectorlight's Free RichTextBox can do a pretty good job of what you need using HTML.
In Silverlight 4 you have the option of using the RichTextBox to represent your content.
If you do get something like that up and running, msg me and maybe we can collaborate on bringing my "BindableFlowDocument" into the world of Silverlight. ;)
edit - wow, I must have gotten mixed up - my original answer was way off
Inline with the comments of SL4 RC's RichTextBox (RichTextArea, circa SL4 Beta), and with your example of importing marked up text, the SL4 RC RichTextBox will allow for an import of XAML formatted text - like string richText = MyRichContent.Xaml; on this page: http://timheuer.com/blog/#richtextbox. Details are listed here: http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.xaml(VS.96).aspx.
Just use the RichTextBox in Silverlight 4.0

Resources