textblock

Why don't OneTime and OneWay databinding work with TextBlock's Text property

In Silverlight 3: I've got an object that implements INotifyPropertyChanged I've got a TextBlock with the Text property bound to a property on my object. However, the property changes and fires the PropertyChanged event, but the TextBlock control never displays the value. If I change the Mode to TwoWay, it works, but this doesn't make...

WPF TextBlock Padding is cutting off text

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"> <Scrol...

wpf: making textblock height expand when text gets too big for 1 line

Hello, I have a listview with an itemtemplate: <ListView x:Name="messages" HorizontalAlignment="Left" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="Black"> <ListView.ItemTemplate> <DataTemplate> <TextBlock Style="{DynamicResource h3}" Text="{Binding}" Margin="10" MaxWidth="850"/>...

WPF TextBlock: How to evenly space displayed characters?

Hi All, I need to display a string with each character displayed every x pixels. (x is accross the whole string). e.g.: "Hello" -> H at position (pixel) 0, e at position 50, l at 100, l at 150, o at 200. Of course I could use a TextBlock for each character but it seems overkill. TranslateTransform doesn't seem to do the trick: It of...

Text vertical alignment in WPF TextBlock

How to make vertical center alignment to the text inside a TextBlock? I found TextAlignment property. But it is for horizontal text alignment. How to do it for vertical text alignment. ...

Programmatically replace GridView cell contents on load

I am working on a program in WPF for the first time. I have a ListView in GridView mode displaying data from a bound dataset (which is grabbed from a database). In my database, "date of birth" is not a required field. As such, any record without a dob had the value set to DateTime.MinValue. On each of these minimum value dates, the date...

Access TextBlock binding path programatically

This is a follow-up question to my previous one about replacing GridView contents programmatically. I have a GridView displaying a DataSet. All of my columns are bound in my xaml with DisplayMemberBinding: <GridViewColumn DisplayMemberBinding="{Binding Path=FirstName}" Header="First Name" ...

Determining How Silverlight 3 TextBlock Wraps Text

I working on a Silverlight app that includes an screen emulator for a handheld device. The idea is that a user can attempt to format text that will display on the device, and see how it will look on the screen. The emulator also attempts to make a "best guess" at formatting a string to fit the device screen. I know I can do the math m...

Problem with ItemTemplate TextBlock

Hi, i am trying to make an item template where some of the field in my stack panel can be empty. When it's empty, I would like to set the visiblility to collapsed. I tried putting triggers but it doesn't seem to work and I am not very familiar with this part of WPF Also, I would like to change the color of the background of this item w...

What the best way to get paragraphs in a WPF textblock? (newline chars?)

Hi, I have some text which has "\r\n" newline markers. I would like to have the newlines in a WPF textblock. I've tried replacing "\r\n" with "& # 13;" (without the spaces), which worked when I set the Text property in XAML, but doesn't seem to work when setting from the C# code-behind. So...what's the standard way to convert "\r\n" to...

ValidationRule - validate on property update

Greetings, how can I validate if value in TextBlock is ok? I have a TextBox where I bind "Amount" property and a TextBlock which uses Multibinding: Price Property and Amount property. I would like to do something like that: In case of changing Amount i would like to validate if the price is greater than xx (which is the constant). Thank...

How do I bold portions of a bound TextBlock?

I have a TextBlock bound to a property. However, I'd like to bold certain words within the text. What is the easiest way to do this? FYI, I'm new to WPF. ...

Why is text being truncated in this Silverlight TextBlock?

I have a TextBlock with wrapping enabled and while the text is wrapping, it is being wrapped in such a way that some text is truncated. The TextBlock is defined as <TextBlock x:Name="_txtLiveText" Style="{StaticResource TranslationInfoTextBlockStyle}" Text="Live text displays here" Width="Auto" TextWrapping="Wrap" Grid....

Silverlight UI Automation of a TextBlock

I'm trying to set up UI automation for Silverlight 3. I have a little test project that has 2 elements, a Button and a TextBlock. When you click the button the text is supposed to change. I have been able to simulate a button click and the text does correctly change on the UI. However I am having problems retrieving the text from t...

WPF - How do I default the Visibility of a databound Textblock?

Hi This Textblock, defined below, shows when the window first loads because it has no Datacontext (and hence the converter code is not run) until an item has been selected from another control e.g. TreeView. <TextBlock Name="tbkDocumentNotFound" Style="{StaticResource StandardText}" Margin="4,4,2,0" TextWrapping="Wrap" ...

WPF/XAML: how to make all text upper case / capital?

hi, here's my problem: I want all texts in TextBlock, Label, MenuItem.Header to be displayed in upper case. The strings are taken from a ResourceDictionary e.g.: <TextBlock Text="{StaticResource String1}"/> <MenuItem Header="{StaticResource MenuItemDoThisAndThat} etc. (also for Label and other controls) I cannot use a value c...

WPF resizing TextBlock

I have a textblock in a grid in WPF. I want the text to dynamically size (font) when resized. At the moment textboxes, comboboxes do this, but the the textblock stays the same. Is it possible? ...

wpf textblock autosize/layout in stackpanel

I have the following stack panel <StackPanel> <TextBlock Text="{Binding AddressLine1}" /> <TextBlock Text="{Binding AddressLine2}" /> <TextBlock Text="{Binding AddressLine3}" /> <TextBlock Text="{Binding AddressLine4}" /> </StackPanel> and my AddressLine2 string is null on the bound object. My stack pane...

Data binding the TextBlock.Inlines

My WPF App receives a stream of messages from a backend service that I need to display in the UI. These messages vary widely and I want to have different visual layout (string formats, colors, Fonts, icons, whatever etc.) for each message. I was hoping to just be able to create an inline (Run, TextBlock, Italic etc) for each message ...

I'm using a WPF TextBlock but then text gets cut off when it's too long. Is there an AutoScroll feature?

My TextBlock has for example 50x50 pixels to display text, however if there is more text, I want a user to be able to scroll. Is there an autoscroll feature for this control? Should I use a different control better suited for this task? Here's a couple of pics to illustrate the problem: This one works fine because the text fits in snu...