472,984 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

wpf - add newline to wrappanel ?

Hello,

I'm trying to create the equivalent of a textbox which could format
different kind of "values" using a string.
Currently i can do this: (myObject is an ItemsControl)

<myObject>
<myObject.Items>
The value of abc is:
<SomeHandler DataContext="{Binding abc}">
The value of def is:
<SomeHandler DataContext="{Binding def}">
<myObject.Items>
</myObject>

A TemplateSelector is used to transform each element into a TextBlock,
and a WrapPanel is used to layout the textblocks, so that resizing the
window keeps all textblocks displayed to user, like a the text in a
web browser.

My question is: how can I do to insert NewLines manually ? Web
browsers have an auto wrap feature, but they also include <br /tags.
What's the easiest way to implement this ? And if it is not posible,
any idea i could do this with or without breaking my code ?

Thanks in advance.
Jun 27 '08 #1
1 7690
"Vivien Parlat" <po****@gmail.comwrote in message
news:b3**********************************@d45g2000 hsc.googlegroups.com...
Hello,

I'm trying to create the equivalent of a textbox which could format
different kind of "values" using a string.
Currently i can do this: (myObject is an ItemsControl)

<myObject>
<myObject.Items>
The value of abc is:
<SomeHandler DataContext="{Binding abc}">
The value of def is:
<SomeHandler DataContext="{Binding def}">
<myObject.Items>
</myObject>

A TemplateSelector is used to transform each element into a TextBlock,
and a WrapPanel is used to layout the textblocks, so that resizing the
window keeps all textblocks displayed to user, like a the text in a
web browser.

My question is: how can I do to insert NewLines manually ? Web
browsers have an auto wrap feature, but they also include <br /tags.
What's the easiest way to implement this ? And if it is not posible,
any idea i could do this with or without breaking my code ?

Thanks in advance.
If you just want to force a new line within a TextBlock you can do this:
<TextBlock>Line1<LineBreak />Line2</TextBlock>
Or, in code:
myTextBox.Text = "Line1" + Environment.NewLine + "Line 2";

However, if you want to force the WrapPanel to wrap after a particular text
block then I don't know of any official way to do it. One very nasty way
would be to insert something like the following where you want the wrap:
<TextBlock FontSize="0.01" Margin="0,0,100000000,0"/>
but I definitely do not recommend it!!!

Chris Jobson
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Alan Mackenzie | last post by:
To all those who use (X)Emacs's CC Mode to edit C, C++, Java, Objective-C, Pike, AWK or IDL: To help direct the development of CC Mode, it would be useful to find out how people use the...
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
4
by: Peter Kirk | last post by:
Hi I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform -...
5
by: Adam Right | last post by:
Hi, Is there a way to construct the mail body including newline characters by using .net framework mailing functions when sending an email? I cannot insert newline character into the body of the...
11
by: rossum | last post by:
I want to declare a const multi-line string inside a method, and I am having some problems using Environment.NewLine. I started out with: class foo { public void PrintStuff() { const...
1
by: linq936 | last post by:
Hi, I read in many places that the string to be outputted by printf() must be ending with newline, for example, it should be printf("Hello World.\n"); instead of printf("Hello World.");
0
by: Vivien Parlat | last post by:
Hello, I'm trying to create the equivalent of a textbox which could format different kind of "values" using a string. Currently i can do this: (myObject is an ItemsControl) <myObject>...
0
by: Vivien Parlat | last post by:
Hello, I'm trying to create the equivalent of a textbox which could format different kind of "values" using a string. Currently i can do this: (myObject is an ItemsControl) <myObject>...
0
by: Chevron Boyde | last post by:
Hi There I have wrap pannel that displays buttons in it. I am looking for some tips on how to handle paging with a wrappanel. Cheers, Chev
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.