textblock

WPF TextBlock Padding is cutting off text

独自空忆成欢 提交于 2019-12-04 05:33:03
I have a TextBlock in a Grid with its Padding attribute set to 5. Sometimes the last character is cut off, depending on what string the Text property is set to. <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SomeClass"> <ScrollViewer Padding="5" VerticalScrollBarVisibility="Auto"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Label Grid.Row="0" Grid.Column=

WPF — it's gotta be easier than I'm making it

為{幸葍}努か 提交于 2019-12-04 04:53:58
I'm having the darndest time figuring this out: say I've got two Button and three TextBlocks. I want either button to trigger a simple Storyboard on ALL TextBlocks. Currently I'm trying to define a generic Textblock style that contains the Storyboard, and then the trigger comes from any Button click. This is the closest I've come but the app crashes on startup...what am I don't wrong here: <Window.Resources> <Style TargetType="TextBlock" > <Setter Property="Foreground" Value="Blue" /> <Style.Resources> <Storyboard x:Key="TextBlockOpacity" Storyboard.TargetProperty="Opacity"> <DoubleAnimation

WPF/XAML: How to make all text upper case in TextBlock?

纵然是瞬间 提交于 2019-12-04 03:52:00
I want all characters in a TextBlock to be displayed in uppercase <TextBlock Name="tbAbc" FontSize="12" TextAlignment="Center" Text="Channel Name" Foreground="{DynamicResource {x:Static r:RibbonSkinResources.RibbonGroupLabelFontColorBrushKey}}" /> The strings are taken through Binding. I don't want to make the strings uppercase in the dictionary itself. Or use Typography.Capitals="AllSmallCaps" in your TextBlock definition. See here: MSDN - Typography.Capitals EDIT: This does not work in Windows Phone 8.1 , only in Windows 8.1 ... kidshaw Implement a custom converter. using System

How to bind a variable with a textblock

烈酒焚心 提交于 2019-12-04 03:31:28
I was wondering how I would be able to bind a text block to a variable within my C# class. Basically I have a "cart" variable in my .cs file. Within that Cart class I have access to the different totals. The following is what I have for binding, but it does not seem to bind to the variable... <StackPanel Width="Auto" Height="Auto" Grid.ColumnSpan="2" Grid.Row="5" HorizontalAlignment="Right"> <TextBlock Name="Subtotal" FontFamily="Resources/#Charlemagne Std" FontSize="20" Text="{Binding ElementName=cart, Path=SubTotal}"> </TextBlock> <TextBlock Name="Tax" FontFamily="Resources/#Charlemagne Std"

Textblock.TextTrimming not working inside a grid

最后都变了- 提交于 2019-12-04 03:17:46
I have a 3 column grid for my layout with each of it width set to Width="*" . For the middle (2nd) grid, I have another 3 column grid each containing it own textblock, and again the column grids width are set to Width="*" . When the Window is resized, the grids are resized as expected, however the 3rd textblock isn't getting trimmed if the text goes outside the boundary of the grid. I have textbox set with TextTrimming="WordEllipsis" and TextWrapping="Wrap" , and the properties are not being enforced for some reason. Here is some of the code I have: Layout grid: <Grid> <Grid.ColumnDefinitions>

WPF: How to make empty TextBlock not to occupy space?

冷暖自知 提交于 2019-12-04 01:44:45
Let's say that I have a simple layout such as this: <StackPanel> <TextBlock Text="{Binding Path=Title}" /> <TextBlock Text="{Binding Path=ShortDescription}" /> <TextBlock Text="{Binding Path=LongDescription}" /> </StackPanel> Now when I have ShortDescription set to null or empty string there's still a gap in place of second TextBlock. Is there some property to prevent an empty textblock from occupying space? Or should I use some other control? Thanks. You want to set the visibility of the textbox to "Collapsed". Visibility can be either: Visible - Self explanatory Hidden - Invisible but still

Auto detect URL, phone number, email in TextBlock

北城余情 提交于 2019-12-03 22:19:54
I would like to automatically highlight URL, Email and phone number in UWP. It is possible in Android but it seems this features has been forgotten by Microsoft. In my use case, I get the text from a web service, so I don't know the text format which is a user text input on the web platform. Vincent The platform is not supporting this feature (yet). When I've to do the same thing, I've ended with my own solution which is to: create an attached property receiving the text to format use some regex to extract the URL, phone numbers, email addresses from it generate an Inlines collection which I'm

WPF Textblock translation based on reference point

我是研究僧i 提交于 2019-12-03 18:12:16
问题 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. 回答1: Maybe you need this void MoveToPoint(UIElement

WPF Multiline TextBlock CenterAlignment Issue [duplicate]

一曲冷凌霜 提交于 2019-12-03 14:23:00
问题 This question already has an answer here : TextBlock.TextWrapping - how to make the text wrap so that the lines are center-aligned? (1 answer) Closed 3 years ago . I'm having an issue with multiline text blocks where it is not center aligning properly The text is coming like abcde\nabc This comes out abcde abc What I want is abcde abc This seems a simple thing and I would have thought that the textblock would center align like that automatically but it does not seem to. 回答1: Try the

Vertically aligning Labels and TextBlocks at Top in XAML

孤者浪人 提交于 2019-12-03 13:23:05
How can I vertically align a Label and TextBlock at Top so that their first lines of text line up? <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> </Grid.RowDefinitions> <Label Grid.Column="0" VerticalAlignment="Top">Some Label:</Label> <TextBlock Grid.Column="0" VerticalAlignment="Top">Some text<TextBlock> </Grid> The above code gives me this: Vertically misaligned Label and TextBlock text http://img156.imageshack.us/img156/4940/labeltextblock.png The extra space around the label comes