473,698 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="{B inding abc}">
The value of def is:
<SomeHandler DataContext="{B inding def}">
<myObject.Items >
</myObject>

A TemplateSelecto r 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 7832
"Vivien Parlat" <po****@gmail.c omwrote in message
news:b3******** *************** ***********@d45 g2000hsc.google groups.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="{B inding abc}">
The value of def is:
<SomeHandler DataContext="{B inding def}">
<myObject.Items >
</myObject>

A TemplateSelecto r 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>Line 1<LineBreak />Line2</TextBlock>
Or, in code:
myTextBox.Text = "Line1" + Environment.New Line + "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,100 000000,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
2510
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 auto-newline "minor mode" facility. If you could spare a little time, would you answer these questions, please: o Do you program with auto-newline switched on (e.g. do you get NLs inserted automatically after typing a `;' or `{')? o Did you configure...
29
3445
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
4485
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 - I assume that it is a runtime property, and not compile time? But won't it always be the same anyway - does dotnet run on anything other than windows platforms? So isn't newline always the same?
5
6986
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 mail. Thanks...
11
6242
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 string multiline = "The first line." + Environment.NewLine +
1
8506
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
1360
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> <myObject.Items> The value of abc is: <SomeHandler DataContext="{Binding abc}">
0
295
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> <myObject.Items> The value of abc is: <SomeHandler DataContext="{Binding abc}">
0
1488
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
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7721
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.