textblock

Any way to make a WPF textblock selectable?

I want to make the text displayed in the Witty, an open source Twitter client, selectable. It is currently displayed using a custom textblock. I need to use a TextBlock because I'm working with the textblock's inlines to display and format the @username and links as hyperlinks. A frequent request is to be able to copy-paste the text. In...

WPF Layout: word-wrapping not working

Why does the text in my TextBlock extend out to the right beyond my canvas even though I specified word wrap? <Window x:Class="WpfApplication6.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" SizeToContent="WidthAndHeight"> <...

How would I databind a Paragraph to a TextBlock?

How would I take a Paragraph object and databind them to the TextBlock for use in a DataTemplate? A plain bind does nothing, just a ToString() of the Paragraph object. The InLines property would let me add a list of TextRun's that make up the Paragraph manually, but that can't be bound to and I could really do with a binding based solut...

Set TextBlock to be entirely bold when DataBound in WPF

I have a databound TextBlock control (which is being used inside a DataTemplate to display items in a ListBox) and I want to make all the text in the control bold. I can't seem to find a property in the properties explorer to set the whole text to bold, and all I can find online is the use of the <Bold> tag inside the TextBlock, but I ca...

How can I bind data to the contents of a Run?

I want to construct a TextBlock consisting of several Run elements, with their contents bound to string variables, but Visual Studio complains, saying that one can only bind to a dependency property, which Run.Text isn't. Is there anything that can be done? ...

Best way to decorate databound text in a wpf TextBlock

Hello, Let's say I have some multiline text that I'd like to format, and let's also say that it's databound. So, in XAML: <TextBlock TextWrap="Wrap"> <TextBlock.Inlines> <Run TextWeight="Bold" Text="{Binding Path=FirstName}" /> <Run TextStyle="Italic Text="{Binding Path=LastName}" /> </TextBlock.Inlines> </Text...

How to hide Label or TextBlock inside a WPF Grid

I am trying to hide the TextBlock and Label which are placed inside a grid like so: <TextBlock Grid.Column="3" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Hidden">Text inside TextBlock</TextBlock> <Label Grid.Column="4" Grid.Row="2" HorizontalAlignment="Center" Visibility="Hidden">Text inside Label</...

Display images in TextBlock (WPF)

Hi, I'm working on a simple chat application. Currently the messages are binded to a custom-styled listbox like this (simplified XAML): <ListBox ItemsSource="{Binding MessageCollection}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Text}"/> </DataTemplate> </ListBox.ItemTemplate> ...

How to display simple HTML in a Silverlight textblock?

I've got a source of data that has HTML tags in it (B, I, A) and need to display this in a Silverlight ListBox. Searching around it seems to be an issue but most of the posts are old and have to do with Silverlight 1 it seems. What is currently the best way to display simple HTML with Silverlight, if nothing else, just the B, I and A ...

WPF TextBlock highlight certan parts based on search condition

Hello, I have TextBlock that has Inlines dynamicly added to it (basically bunch of Run objects that are either italic or bold). In my application I have search function. I want to be able to highlight TextBlock's text that is in being searched for. By highlighting I mean changing certain parts of TextBlock text's color (keeping in mi...

WPF Textblock, linebreak in Text attribute

Is there a way to have \n make a linebreak in a TextBLock? <TextBlock Text="line1\nLine2" /> Or is there a better way to force a middle line break, inside the Text="" attribute? <linebreak /> ????? This doesn't work for me, it needs to be the value of the Text="" attribute, because the text string is being set from an outside sourc...

Problem with TextBlock.ActualWidth in Silverlight 2.0

Lets say I have some XAML like this: <StackPanel> <TextBlock Text="Blah Blah Blah" /> </StackPanel> In this case, the Width is NaN, as I expect, because it grows with the size of the StackPanel and is not explicitly set. Unfortunately, ActualWidth does not give me the results I expect. ActualWidth is not bound by the size of the...

How can I determine if my TextBlock text is being trimmed?

The following textblock wraps and trims as expected. The elipsis "..." is displayed when the text is trimmed. <TextBlock MaxWidth="60" MaxHeight="60" Text="This is some long text which I would like to wrap." TextWrapping="Wrap" TextTrimming="CharacterEllipsis" /> I would like to display a tooltip over the text ...

My databinding with value converter does not work

I've got a simple Item-class, that looks like this: public class Item : DependencyObject { public int No { get { return (int)GetValue(NoProperty); } set { SetValue(NoProperty, value); } } public string Name { get { return (string)GetValue(NameProperty); } set { SetValue(NameProperty, value); } } public static readonly D...

How can a user enter a newline character in Silverlight?

I'm trying to get a screen in silverlight where the user can enter their own text and add line breaks as neccesary. The problem is that whenever they hit return inside of a text block, nothing happens. Is there some way around this? Thanks ...

Vertically aligning Labels and TextBlocks at Top in XAML

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

Poor Performance When Dynamically Resizing a WPF TextBlock

I'm currently working out the layout of a WPF Application and seem to have it a bit of a snag in the layout of one of my controls. This control is a dynamically sizing, so it should fit the size of the viewport it's a part of. The problem I'm running into is a very visual problem, so I'll do my best to describe it. Here's what it looks l...

Silverlight TextBlock and textbox

I'm trying to figure out how to change the font size of a textblock and textbox in Silverlight 2.0. in code behind. So far i've had no luck getting it done or find a referrence on how to do it. thanks shannon ...

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

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

wpf rotate and translate transform issue on textblock

Hi, I've got a list of strings I'm binding to an items control. The strings are displayed in textblocks I've declared in the itemscontrol template. I've rotated the textblocks 270 so that the text is on its side - I've also translated the textblocks down by their width so that they are at the top of the page. My issue is they are now...