Line breaks in windowsphonetoolkit custom message box - windows-phone-8

Using the windowsphonetoolkit how can one force line breaks in the message text to nicely format it. It appears that the stardard "\n" and "\n\r" line breaks do not work.
So something like:
This is the first line
and
This is another line.

You can achieve that by setting your message in Content property instead of Message. Then the message could be just a TextBlock where you can do whatever you want.
If you're doing your custom message box in XAML, the could look like this:
<toolkit:CustomMessageBox Caption="Caption"
LeftButtonContent="ok"
RightButtonContent="cancel">
<TextBlock Margin="12"
FontSize="{StaticResource PhoneFontSizeMedium}"
FontFamily="Segoe WP SemiLight">First line<LineBreak />Second line</TextBlock>
</toolkit:CustomMessageBox>
But you can also make it in code behind:
CustomMessageBox messageBox = new CustomMessageBox()
{
Caption = "Caption",
LeftButtonContent = "ok",
RightButtonContent = "cancel",
Content = new TextBlock()
{
Margin = new Thickness(12),
FontSize = (double)Resources["PhoneFontSizeMedium"],
FontFamily = new System.Windows.Media.FontFamily("Segoe WP SemiLight"),
Text = "First line" + Environment.NewLine + "Second line",
},
};
// messageBox.Show();
Result:

Related

ChromiumWebBrowser - how to set height to HTML doc height

I have a chromiumWebBrowser hosted in my application.
user can navigate between html pages (with binging to address).
I need xaml scroller (not css), so I have a scrollViewer and inside the Chromium browser.
Every time the Address changes, chromium height needs to be full html doc height, to get the scrolling right.
I have tried setting it similar to answer in this Q:
cefSharp ChromiumWebBrowser size to page content
which works well first time, but when navigating, it only grows - if first page is 600, and next is 200 - it returns 600 second time too.
XAML:
<ScrollViewer x:Name="scroller" >
<wpf:ChromiumWebBrowser x:Name="chrome"
Address="{Binding CurrentUrl}" />
</ScrollViewer>
C#:
chrome.LoadingStateChanged += async (s, e) =>
{
if (!e.IsLoading) // browser.CanExecuteJavascriptInMainFrame == TRUE !
{
JavascriptResponse response =
await chrome.EvaluateScriptAsync(
// GET HEIGHT OF CONTENT
$"(function() " +
"{ var _docHeight = " +
" document.documentElement.scrollHeight; " +
" " +
" return _docHeight; " +
"} " +
")();");
int docHeight = (int)response.Result;
chrome.Dispatcher.Invoke(() => { chrome.Height = docHeight; });
}
};

How to wrap text in the Label without specifying height of the element

Problem is that I can't set the height of the Label. For a long text my Label should have height for 2 rows, with a short text only 1 row.
There is code example:
public MyComposite(Composite parent) {
super(parent, SWT.NONE);
setLayout(new GridLayout(1, false));
description = new Label(this, SWT.WRAP);
description.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
description.setText("Looooooooooooooooooooooooooooooooooooooo" +
"oooooooooooooooooooooooooooooooooooooooooooooooooooooo" +
"ooooooooooooooooooooooooooooooooooooong text");
}
To enable wrapping text in a GridLayout, you have to set the 3rd parameter of the GridData (grabExcessHorizontalSpace) to true. Also make sure that the parent composite's size is defined by its layoutData, otherwise it will be expanded by the Label. The following snippet has the label text wrapped:
Shell shell = new Shell( parentShell );
shell.setSize( 400, 300 );
shell.setLayout( new GridLayout(1, false) );
Label description = new Label(shell, SWT.WRAP);
description.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
description.setText("Looooooooooooooooooooooooooooooooooooooo" +
"oooooooooooooooooooooooooooooooooooooooooooooooooooooo" +
"ooooooooooooooooooooooooooooooooooooong text");
shell.open();
Also note that wrapping is implemented as word-wrap, a very long sequence of non-whitespace characters won't be split into lines.

Displaying more than one content in a cell in asp.net

I have a cell and want to display 'hello' in the middle and if some condition is true then display 'world' at the right bottom of that cell.
Here, Only hello and world is getting displayed but 'world' not at the right bottom.
tc.InnerHtml = "Hello";
if(some condition)
{
Label lblBundle = new Label();
lblBundle.Style.Add("font-size", "5px");
lblBundle.Style.Add("float", "right");
lblBundle.Style.Add("float", "bottom");
lblBundle.Text = "world";
tc.Controls.Add(lblBundle);
}
Can anyone please help me out. I am displaying the label control dynamically.
if you want to append just word to existing content than why you need to add label. try following:
tc.InnerHtml = tc.InnerHtml + " world"

How to add <Bold></Bold> text to the content of a TextBlock in WinRT?

I want to create this programmatically:
<TextBlock Style="{StaticResource WordStyle}" x:Name="Foo"><Bold>d</Bold>o o<Bold>dd</Bold></TextBlock>
I found the answer. To add bold text, italic text and line breaks or change the foreground color or font family using C#, the TextBlock.Inlines property works perfectly.
Foo.Inlines.Clear();
// Bold text.
var block = new Run();
block.Text = "d";
block.FontWeight = FontWeights.Bold;
Foo.Inlines.Add(block);
// Regular text.
block = new Run();
block.Text = "o o";
Foo.Inlines.Add(block);
// Bold and italics text.
block = new Run();
block.FontStyle = FontStyle.Italic;
block.FontWeight = FontWeights.Bold;
block.Text = "dd";
Foo.Inlines.Add(block);

dynamically change the color for every line in textarea and panel using flex 4 and action script 3

I have created a simple text chat application for android device using flex 4 and action script 3. in the text chat I have given a option for change font color. I have used "TextInput" for enter text message and "Textarea" for shows the chat messages. when I change the color of the text, all the lines in the "textarea" color has been changing.
textoutput.setStyle("color",textInput.getStyle("color"));
textoutput.text += userNameInput.text + ": " + msg + "\n";"
this is the code I have used. but I need to change the color for every line in the "textarea".
In the other hand, i have created the panel for display chat, and dynamically created the label for the message and dynamically I have changed the color but all the lines are merging in same line. I need to add line break for every dynamic label in the panel window.
var mylabel:Label=new Label();
mylabel.setStyle("color",textInput.getStyle("color"));
mylabel.text += userNameInput.text + ": " + msg + "\n";
panelId.addElement(mylabel);"
this is the code I have used for adding dynamic label into Panel . can any one kindly suggest me some idea for solving any one of this problem means that should be very helpful for me. thanks in advance.
Here is some info that might be helpful , from http://help.adobe.com/en_US/as3/dev/WS8d7bb3e8da6fb92f-20050207122bd5f80cb-7ff5.html
Formatting ranges of text within a text field
A useful method of the flash.text.TextField class is the setTextFormat() method. Using setTextFormat(), you can assign specific properties to the contents of a part of a text field to respond to user input, such as forms that need to remind users that certain entries are required or to change the emphasis of a subsection of a passage of text within a text field as a user selects parts of the text.
The following example uses TextField.setTextFormat() on a range of characters to change the appearance of part of the content of myTextField when the user clicks the text field:
var myTextField:TextField = new TextField();
myTextField.text = "No matter where you click on this text field the TEXT IN ALL CAPS changes format.";
myTextField.autoSize = TextFieldAutoSize.LEFT;
addChild(myTextField);
addEventListener(MouseEvent.CLICK, changeText);
var myformat:TextFormat = new TextFormat();
myformat.color = 0xFF0000;
myformat.size = 18;
myformat.underline = true;
function changeText(event:MouseEvent):void
{
myTextField.setTextFormat(myformat, 49, 65);
}