textblock

Add carriage return to string resource in WPF

主宰稳场 提交于 2019-11-30 13:51:22
问题 My applications store all localized text in a string resource dictionary as suggested here http://msdn.microsoft.com/en-us/library/bb295251(VS.85).aspx <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:system="clr-namespace:System;assembly=mscorlib"> <!-- String resource that can be localized --> <system:String x:Key="localizedMessage">en-US Message</system:String> </ResourceDictionary> My

Is there any difference between WPF TextBlock and TextBox?

时光怂恿深爱的人放手 提交于 2019-11-30 11:14:03
问题 What criteria must I consider when selecting one of these two controls? 回答1: Common to both TextBlocks and TextBoxes: Can be used to display text Can be set to specific Height and Width or be set to Auto so that they grow in size with the text. Can set font size, font type, font styling, to wrap and to range left, right or centred. Can have opacity set and have Pixel Shaders applied. TextBlock: Used for displaying text more focused typographically. Can contain text set to different colors,

TextBlock with multiple <Run> spacing

六月ゝ 毕业季﹏ 提交于 2019-11-30 10:48:15
Given a formatted text block in Windows Phone 7.1 project: <StackPanel Orientation="Horizontal"> <TextBlock Foreground="DarkGray" VerticalAlignment="Bottom" Margin="0,0,0,8"> <Run Text="total length "/> <Run Text="{Binding TotalHours}" FontSize="48"/> <Run Text="h "/> <Run Text=":" FontSize="48"/> <Run Text="{Binding TotalMinutes}" FontSize="48"/> <Run Text="m "/> </TextBlock> </StackPanel> It is being previewed correctly in VS designer: It is already looking not the way I want in Blend: It looks just as in Blend (good job Blend team) in emulator and a real device. What adds those spaces

C# WPF - ScrollViewer + TextBlock troubles

主宰稳场 提交于 2019-11-30 08:13:19
I have a TextBlock within a ScrollViewer that aligns with stretch to its window. I need the TextBlock to behave as the following: Resizes with window, no scrollbars When resized below a certain width the TextBlock needs to keep a MinWidth and scrollbars should appear TextWrapping or TextTrimming should work appropriately How can I get this functionality? I have tried several ways, involving bindings to ActualWidth & ActualHeight , but can't get it to work. This can't be that difficult, what am I missing? Here is a code sample to put in XamlPad (no MinWidth is set yet): <Window xmlns="http:/

how many characters can a Silverlight TextBlock hold?

安稳与你 提交于 2019-11-30 07:42:29
问题 i am trying to put a end-user license agreement (EULA) into a WP7 silverlight textblock control. however, it keeps truncating my text. why is this happening? is there a limit on the text size or number of characters a WP7 silverlight textblock can hold? below is an example of what i've done in terms of xaml (the rest of the xaml surrounding is the default that is auto-generated). <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <ScrollViewer> <TextBlock x:Name="tbMsg" TextWrapping

Is there any difference between WPF TextBlock and TextBox?

余生长醉 提交于 2019-11-29 23:31:41
What criteria must I consider when selecting one of these two controls? Rohit Common to both TextBlocks and TextBoxes: Can be used to display text Can be set to specific Height and Width or be set to Auto so that they grow in size with the text. Can set font size, font type, font styling, to wrap and to range left, right or centred. Can have opacity set and have Pixel Shaders applied. TextBlock: Used for displaying text more focused typographically. Can contain text set to different colors, fonts and sizes. The line height can also be increased from the default setting to give more space

How to a add a command to a WPF TextBlock?

岁酱吖の 提交于 2019-11-29 22:01:17
I'd like to be able to click a textblock and have it run a Command. Is this possible? (if not do I just somehow make a tranparent button over it or something?) You can use a InputBinding . <TextBlock Text="Hello"> <TextBlock.InputBindings> <MouseBinding Command="" MouseAction="LeftClick" /> </TextBlock.InputBindings> </TextBlock> Edit: Hyperlink is probably worth a mention too. <TextBlock><Hyperlink Command="" TextDecorations="None" Foreground="Black">Hello</Hyperlink></TextBlock> You do not make a transparent button over it, you put the TextBlock into it: <Button> <Button.Template>

Binding in TextBlock doesn't work in WPF

余生长醉 提交于 2019-11-29 17:03:30
I want to dynamically change TextBlock text in my Class. XAML-Code : <TextBlock Name="Footer_text" Text=""/> C# : string footerMainMenuText = "Setting"; Binding set = new Binding(""); set.Mode = BindingMode.OneWay; set.Source = footerMainMenuText; Footer_text.DataContext = footerMainMenuText; Footer_text.SetBinding(TextBlock.TextProperty, set); I checked last line, and the Footer_text.Text is set correctly. ( Footer_text.Text="Setting" ), but TextBlock in my application doesnt show "Setting". What is the problem here? If you are binding - why not just do it in XAML instead? Looking at your

TextBlock.TextWrapping - how to make the text wrap so that the lines are center-aligned?

℡╲_俬逩灬. 提交于 2019-11-29 16:04:44
问题 In a Windows Phone 7 application, when I place a TextBlock in the grid and set its HorizontalAlignment to " Center " and its TextWrapping to " Wrap ", why does the text that overflows the width of the container and is placed on the next line, align with the left side of the otherwise center-aligned block? Is there any way to setup text wrapping so that all of the text in the text block is center-aligned? 回答1: You are probably missing TextAlignment : <TextBlock TextAlignment="Center" />

WPF Textblock translation based on reference point

北战南征 提交于 2019-11-29 16:02:48
Please check the attached image. I made the textblock origin to it's center by RenderTransformOrigin="0.5,0.5". Now I would like to move the textblock based on the reference point. May be (0,0 ) or (10,10) or ...... These are absolute points. For example, in case of (0,0) the textblock should move to absolute (0,0) based on its reference point. I know how to move relatively by TranslateTransform, but this case I need absolute transform. Maybe you need this void MoveToPoint(UIElement sender, Point point) { Canvas.SetLeft(sender, point.X - sender.RenderTransformOrigin.X * sender.ActualWidth);