I am creating a calculator app and i want to display x2 in button content, in XAML.
I have tried the <sup> tag but it's giving an error.
You can set button text to xยฒ - "x\u00b2"
You just want the text (Content) of the button to have xยฒ written?? Then you simply want superscript character 2.
Then you can just copy and paste the text above ;)
here is the list of unicode characters-
http://www.fileformat.info/info/unicode/category/No/list.htm
That should work:
<Button Content="xยฒ"/>
Related
Here is my context :
We are using WPF to create an new Windows user interface for our product. As we are cross-platform, all information as Label.Content or Button.Content are known in an other part of the application (written in C), and not defined in XAML.
Here is the problem :
We want to handle Strings that we put in a WPF component's content.
I see that we have some attributes as
Label.Content.FontFamily or Label.Content.Size, but graphic attributes are not necessary the same for all the String.
For exemple :
This is my label's content : "Hello guys, thank you to help me". Is it possible to
Underline "thank you"
Change all uppercases in Red color
Change the size of these uppercases
Actually, we are using WinFroms to do that, but it is time to renovate the GUI, because Winforms are just ugly now.
Thanks a lot !
The TextBlock's Content property (Text) expects a collection of Inline elements (InlineUICollection), you have the following available:
Inline
InlineUICollection
LineBreak
Run (defines Text property)
Span (defines Inlines property)
Bold
Italic
Underline
(Inlines is the Content property for span and it's an InlineUICollection, meaning that you can add Run and LineBreaks and other Spans/Bold/Italic inside Span.)
Using this it is possible to "Hello guys, thank you for helping me":
<TextBlock><Run Text="H" FontSize="20" Foreground="Red"/><Span>ello guys, <Underline>thank you</Underline> for helping me</Span></TextBlock>
The H will be red and bigger, and thank you will be underlined.
This is all possible programmatically as well, for example, "hello world" using a run in a textblock:
TextBlock t = new TextBlock();
t.Inlines.Add(new Run{Text="Hello World"});
I'm developing wp8 application for reading Twitter. I read, that RichTextBox can detect links, it's good. But, I want to make next functionality: if in tweet text exist symbol "#" - make a hyperlink with world after "#", which will open a new page like /DetailsPage.xaml?name=#name and show additional info about user. The same thing with #, but open page with tweets which has this hashtag. Is there any way to make it?
Very simple, use the following XAML:
<RichTextBox>
<Paragraph>
<Hyperlink NavigateUri="/Page1.xaml">click me!</Hyperlink>
</Paragraph>
</RichTextBox>
This will display text click me! which looks like a hyperlink and can be clicked. When clicked, it will take you to Page1.xaml in your project.
You will obviously need to create content dynamically for RichTextBox, but I will leave it as an exercise.
Is there a way to make a string bolder in code behind using C# .NET?
I tried:
string TypeofDay = "<span style='font-weight: bold'>Type Of Day</span> ";
txtbox.Text = TypeofDay + ": " + "Delivery Day"
I am concatenating TypeofDay(bold) and "Delivery Day" to display in a textbox.
You can't make some bits bold and some bits not bold, in an <asp:TextBox>.
You can't make text bolder by enclosing text value in tags. You must change attribute of a control that displays that text for example by setting its CSS class or changing code-behind property:
txbSendMessageBody.Font.Bold = true;
PS. I am concatenating few bold strings and some other strings to display in a textbox.
A HTML text box does not support this. ASP.NET (usually) generates HTML; if HTML does not support this, you cannot solve it from the server side.
A bit hacky alternative can be to use Unicode bold characters
http://qaz.wtf/u/convert.cgi?text=Type+Of+Day
txtbox.Text = "๐ง๐๐ฝ๐ฒ ๐ข๐ณ ๐๐ฎ๐: ๐ฃ๐พ๐
๐๐๐พ๐๐ ๐ฃ๐บ๐"
You could layer a div on top of the textbox. Since the text formatting would change anyway once the user started typing, you can just hide the div once focus is given to the div, thus showing the text box. If nothing is entered and focus is lost, show the div again.
TextBox, no, however you could use a label.
myLabel.text = "<b>bold text</b> normal text <u>underlined text</u> <span style='font-size:Large; color:Red'>Big red text</span>";
I am creating a form in C# and need to display text on the form. I need some of the text to show up in a bulleted, unordered list. Is it possible to do this while using a label? Or a rich text box? I am not using ASP.NET and this is for a desktop app.
My message should look like this:
To continue please selected one of the actions below:
Click ButtonA to do this action.
Click ButtonB to do this action.
Thanks!
Just to add as a suggestion to the OP, I have found that using a StringBuilder to construct multi-line messages helps me keep the formatting straight:
StringBuilder messageBuilder = new StringBuilder(200);
messageBuilder.Append("To continue, please select one of the actions below:");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button A to do this action.");
messageBuilder.Append(Environment.NewLine);
messageBuilder.Append("\t\u2022 Click Button B to do this action.");
MessageBox.Show(messageBuilder.ToString());
You can use ASCII or UniCode characters, and reformat your string to replace a marker character with the formatting character.
Say you defined your string like so:
var myMessage = "To continue please selected one of the actions below: * Click ButtonA to do this action. * Click ButtonB to do this action."
you could do a Regex.Replace that looked for asterisks and converted to bullets:
var formattedString = Regex.Replace(myMessage, "\*", "\r\n \u2022");
Since the string was defined on one line, we also put in a newline ("\r\n").
If you'll take a look at the Character Map (Start > Programs > Accessories > System Tools > Character Map), you can locate the keystroke "code" for most characters.
For Arial Text, the "Middle Dot" keystroke combination is:
Alt+0183
To place this in your text using Visual Studio, hold down the Alt key while typing in "0183" on the Numeric Keypad (not the keys over the alpha pad).
This should give you "ยท" in your text.
That's as close as I have come.
Note that other special characters (degrees - Alt+0176 ยฐ, copyright - Alt+0169 ยฉ, and many others) can be included with this technique.
Yes you can use text below:
const string text = #"To continue please selected one of the actions below:
. Click ButtonA to do this action.
. Click ButtonB to do this action.";
label1.Text = text;
You can use special characters for the bullet as well such as *.
You could use a WebBrowser control. I.E.:
WebBrowser webBrowser1 = new WebBrowser();
webBrowser1.DocumentText 1 = "<li>Click ButtonA ...</li><li>Click ButtonB ...</li>"
I have a textbox as follows:
<asp:TextBox runat="server" ID="txtOtherApps" Height="400" Width="400"
TextMode="MultiLine" ontextchanged="txtOtherApps_TextChanged" ></asp:TextBox>
How to display link in this textbox?
The TextBox allows you to display text which the user can edit. It does not allow you to display anything but plain text. To display a URL in the TextBox, simply set its Text property:
txtOtherApps.Text = "http://www.example.com/";
It wont, however, be a "link". Clicking the URL will cause a text cursor to be placed, allowing for the user to edit the URL.
It is possible if you use JavaScript
Use JavaScript on your text element - such that:
<input type="text" name="t1" id="t1" value="http://www.google.com" onmouseover="this.style.cursor='pointer' ;" onClick="window.open(this.value);"/>
Only Java script can do what you are asking for.
You won't be able to click on the link, but you can just set the Text property of the TextBox to the URL.
ASP.NET will render TextBoxes as textareas (in your case, because it's multiline) or inputs. These are standard HTML fragments which are just plain text containers. You can style them, but you can't really linkify the contents of them.
If you really just want to put the text of a link into a box, do this:
// either from the server:
txtOtherApps.Text = YourLinkString;
// or from the client:
<script>
document.getElementById('<%=txtOtherApps.ClientID%>').value = YourJsLinkValue;
</script>
If you want something to happen with the user clicks on the text area, you can add an onclick handler to it...but this would be weird.
You will need a RichTextBox. The .NET one is not available for web applications, but there are a few third party solutions available.
http://www.richtextbox.com/ is one of them, you will have to see for yourself if there is any available that suits your needs better.