Silverlight 4 RichTextbox Paragraph Margin or similar? - silverlight

I'm trying to add bullets to the SL4 RichTextBox. Using the Run / Paragraph objects and adding the correct bullet child seems to be an easy approach. However, when I want to apply a bullet to an existing paragraph, I would like to indent the content of the paragraph. How can apply this kind of styling to the paragraph? The margin doesn't exist for the SL version of Paragraph.
Thanks.

you have to find the Paragraph elements manually and insert corresponding character (bullet or tab) in each Paragraph. Check out this link:
http://www.codeding.com/?article=22

Related

Write text with bullets and numbering WPF

I need to insert into a border text with bullets (look at the next picture for example):
Is there any special property for this or should I use some container like grid and get this manually?
If your solution rely on Expression Blend it fine by me (I`m using Blend 4).
Thanks
Ofir

Search for words like in chrome

this is how Chrome finds you a word when you search for it:
1) select it in all the places it appears.
2) draw little line in the scroll bar wherever it found the searched word.
I have a canvas with scroll view around it, and I want to perform the same thing on it.
I gues that for enabling the selection i'll have to use only richtextboxes ?!? (hope not).
any third party or idea or anything will be highly appreciated
Without looking directly at the Chormium Project (which is open source and available at Chormium Homepage) I would imaging what is happening on this particular example is something following these steps:
Word Highlighting
Search the page source/content for the keyword using a simple regex
Insert that text into some form of a HTML container (either a span or a div) with a particular id
Use CSS to style that container to indicated the highlighting
Sidebar Highlighting
Use some algorithmic method to vertical position of the highlighted term
Add a indicator to the side bar in a some presentation layer/control that is transparent and below the scroll bar
It may be possible that there exists a 3rd party control that does these things, or it may be possible to leverage your work off of the existing work in the chromium project. However it is most likely not done using a RichTextBoxes nor simple text selection.

Bullets and Numbering in Silverlight

I'm looking for some comprehensive library for Silverlight on bullets/numbering. I've found a few, like Vector Light's RTB control, but most are lacking extended features of bullets/numbering that word processing programs have, like having the First Line Indent of a great value than the Hanging Indent (e.g. first line indent is 1 inch and hanging indent is .5 inch). Another example is customizing the size of the bullet/number Anyone know of good libaries for this for Silverlight?
Check out the ordered/unordered list controls explained in this link. You can extend its functionality to acheive what you intend to do. I have used it to show hierarchical data using nested lists and found it fairly easy to modify it to my needs.
that implementation works for read-only content only.
What if you need to apply bullets/numbering/indent to selected-text in a RichTextBox?
You have to programmatically find Paragraph elements inside selected-text and insert the corresponding character (bullet or number of tab) at the start of each Paragraph element.
Check out here for detailed explanation: http://www.codeding.com/?article=22

Silverlight 3 - Control over wrapping in TextBox

Ok I have the following problem in Silverlight. I have a control with 2 columns. On the left is a stack panel with line numbers and on the right is a textBox.
So when I write in textBox without wrapping turned on I can simply create the right count of numbers on the left, because I'm searching for '\r' in text.
But when I turn on wrapping I have no control over the count of lines in textBox.
Is there a way to get to that count? Or a way to know which line in textBox is going to wrap?
I hope you can understand what I'm trying to do.
There's one way to do this. You can simulate the word wrap operation in the background using a TextBlock. Here is a good link of the complete solution to this problem.
Extended TextBox control with MaxLines property
Is it not possible to create your items in code before they are passed to the view. This would enable you to bind a list of items to a listview and style them as you wish.
You need to user a value converter to count the number of char / lines and then trim that number if you wish to. Unless you use fixed width, you can't really count or calculte in advancet the size, since each application might be displayed differently (due to different sizing option).
There are two great sample chapters on Windows Phone and Silverlight for Windows Phone on the LearningWindosPhone.com site. There is great Windows Phone Trainng material , and dont forget the Windows Phone Develoeprs Blog
Yes there is a way to get the number of lines occupied by the text in the textbox. It's not that simple though 'coz you have to simulate the behavior of the word wrap in order to count/predict the number of lines generated as a result of a word wrap. I have the solution described here in detail.

Paragraph formatting in a WPF RichTextBox?

I need to apply paragraph formatting to a selection in a rich text box. My RTB will behave the same way as the rich text boxes on StackOverflow--the user can type text into the RTB, but they can also enter code blocks. The RTB will apply very simple formatting to the code block--it will change the font and apply a background color to the entire block, similar to what you see in the code block below.
Changing the font is pretty straightforward:
var textRange = new TextRange(rtb.Selection.Start, rtb.Selection.End);
textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, "Consolas");
textRange.ApplyPropertyValue(TextElement.FontSizeProperty, 10D );
Now I need to apply some paragraph-level formatting. I need to set the paragraph margin to 0, so I don't get a blank line between code lines, and I need to set the paragraph background color. Here's my problem: I can't figure out how to get the paragraph elements from the selection, so that I can apply formatting.
Any suggestions? An example of how to apply the Margin and Background properties would be incredibly helpful. Thanks!
Oh, that was easy.. Came across the answer with a little more research:
var textRange = new TextRange(TextBox.Selection.Start, TextBox.Selection.End);
textRange.ApplyPropertyValue(TextElement.FontFamilyProperty, "Consolas");
textRange.ApplyPropertyValue(TextElement.FontSizeProperty, 10D );
textRange.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(0));
textRange.ApplyPropertyValue(Paragraph.BackgroundProperty, "LightSteelBlue");
The only limitation is that the highlighting still extends only as far as the text, rather than to the right side of the control. I'll leave this question open for a couple of days; if someone can tell me how to extend the background to the right edge of the control, I'll accept your answer to this question.

Resources