textblock

Binding occurs before Validation

Gentlemen, I have a button bounded on Validation.HasError property of a textblock. The textblock has a validation rule that checks the value entered by user. The purpose of the binding is that the button should be disabled if the user enters a wrong data. The problem is that the ValidationRule executes AFTER the binding. So when the u...

WPF Text overflow

I'm currently trying to make it so that when I take a string, it fills up the first textblock until it overflows and then it should start in textblock 2. Currently, I have it to where the string is cut into two pieces at the last end of the last word before it hits what I guess to be the max characters that can fit into textblock one, an...

Adding Text to Textblock in StackPanel does not move Image, Silverlight

I have the following xaml: <StackPanel Orientation="Horizontal" x:Name="HeadlineSP"> <TextBlock x:Name="CanvasHeadline" Text="Sample" Margin="8,8,0,0" /> <Image Source="http://localhost/myimage.png" /> </StackPanel> when i update the text of CanvasHeadline the Image does not move right to left dependiong on the wid...

Textblock added to Panel resizes itself automatically

Hi, I have a custom Panel for laying out text. There is a DependancyProperty called "Text" and when that value changes, this piece of code runs: if( !string.IsNullOrEmpty(Text)) { Children.Clear(); foreach (char ch in Text) { TextBlock textBlock = new TextBlock(); textBlock.Text = ch.ToString(); text...

Silverlight Textblock set lines...

Hi All, I have to develop a control having one datagrid. now datagridtextcolumn have to be binded with one property of collection created in viewmodel. based on data i have do one thing... if for a row no of lines is more than 3 in last column's cell then show a button having text "More" with last cell else with text "Less" and on click...

Apply a style to TextBlocks within a ContentPresenter in Silverlight

If I have the following style defined: <UserControl.Resources> <Style TargetType="TextBlock" x:Key="ProblemStyle"> <Setter Property="FontSize" Value="40"/> <Setter Property="FontWeight" Value="Bold"/> </Style> </UserControl.Resources> Then when I have a ContentPresenter data bound to a string, in WPF I can get ...

How to hit test individual characters in a Silverlight TextBlock

This is a slightly abstract question, for which I apologize. I am not necessarily looking for a specific tested solution, but rather some suggestions that I can experiment with to find the one that works the best. All suggestions are welcome - the more varied and creative the better. Here's the problem: I have a Silverlight TextBlock t...

How to set current CultureUI via XAML binding

I have a TextBlock bound to a string. I want the string to be displayed in current UI culture of the application. I want to do this in XAML. The text block is simple like below. <TextBlock Text="{Binding Path=Text}"/> ...

How to set height of textblock/textbox to 3 lines?

I can set fixed height in pixels, but i'd like to set it in lines. Sort of like in html you can set height of an textarea to number of rows/lines. ...

WPF Measure Text inside TextBlock

I have a textblock that contains some text but the text is always going to vary length and I need to render a bitmap out of this textblock. The problem is the textblock doesn't have a height, width, actual height, actual width, or desired size since I set the height and width to Double.NaN so the textblock would auto size. This causes ...

WPF TextBlock Displaying String Over Multiple Lines

I have a string: Item A\r\nItem B\r\nItem C How can I bind this string to a TextBlock so that it appears as: Item A Item B Item C Thanks ...

WPF: Setting Foreground of a Label inside a TabItem Header using styles

Hello, I have a TabControl which looks like this: <TabControl> <TabItem> <TabItem.Header> <StackPanel Orientation="Horizontal"> <Canvas ... /> <Label>Tab Number 1</Label> </StackPanel> </TabItem.Header> </TabItem> <TabItem> <TabItem.Header> <StackPanel Orientation="Horizontal"> ...

Binding wpf textblock to static class property

Hi, I want to bind a textblock text to a property of a static class. Whenever the property value of the static class changes, it should reflect to the textblock which is on the other window or custom control. Thanks ...

Highlight Search TextBlock

My goal is to create a custom TextBlock control that has a new dependency property, SearchText. This property will contain a regular expression. All occurrences of this regular expression in the text of the TextBlock will be highlighted using a custom style (another DP). My current implementation involves clearing all of the Inline obje...

Is there a way to underline one character in a WPF TextBlock?

Is there a way to apply an underline text decoration to one character only in a TextBlock (or any amount less than the full block)? I have some text that I want output as "this worf is misspelt" and have the f in worf underlined. I know you can do: TextBlock47.TextDecorations = TextDecorations.Underline; but I don't want the entire ...

Letterspacing (tracking) with TextBlock in WPF?

What is the best way to do letterspacing (tracking) with TextBlock in WPF? I would think TextBlock.Typography would have taken care of this but it doesn't. What is the best approach? ...

Add carriage return to string resource in WPF

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:S...

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

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 wrap...

Rich formatting of text in a TextBlock using only DataBinding in XAML

I am trying to format a Tweet using Data Binding. What I need to do is split the Text value of the tweet based on what type of content it is. text = "This is a Tweet with a hyperlink http://www.mysite.com" I need to add some color formatting to the http://... portion of the text value. Here's the kicker, I'd like to do this using o...