textblock

Why isn't TextBox.Text in WPF animatable?

Ok, I have just run into something that is really catching me off-guard. I was helping a fellow developer with a couple of unrelated questions and in his project he was animating text into some TextBlock(s). So, I went back to my desk and recreated the project (in order to answer his questions), but I accidentally used TextBox instead o...

Can I have multiple colors in a single TextBlock in WPF?

I have a line of text in a textblock that reads: "Detected [gesture] with an accuracy of [accuracy]" In WPF, is it possible for me to be able to change the color of the elements within a textblock? Can I have a textblock be multiple colors? For example, I would like the whole TextBlock to be black except the gesture name, which I wo...

WPF - TextBlock - Cannot override OnRender

Hi, I am creating a custom control by deriving TextBlock, my intention is to do some custom rendering based on some dependency properties. However the OnRender method is sealed on TextBlock. Although I can get my work done by overriding OnRenderSizeChanged, this is not correct. Any ideas on how can i do it the right way? Thanks in adva...

What is the easiest way to remove the Silverlight TextBox mouse hover border?

I want to display text in a Silverlight application so that the user can copy and paste it elsewhere (as one is used to doing on an HTML web site). If I use TextBlock, then the user cannot copy and paste. Therefore I use TextBox, but it has a default border on it. I can remove the border with BorderThickness="0" like this: <TextBox ...

WPF Textblock Convert Issue

am usina text block in usercontrol, but am sending value to textblock from other form, when i pass some value it viewed in textblock, but i need to convert the number to text. so i used converter in textblock. but its not working <TextBlock Height="21" Name="txtStatus" Width="65" Background="Bisque" TextAlignment="Center" Text="{Bindin...

How do I measure the size of a TextBlock in WPF before it is rendered?

I have a WPF DataTemplate with two TextBlock controls (stacked) and then some other elements underneath. Due to some complicated layout code, I need to know the height of the two TextBlock elements so that I can draw some fancy connector lines, and line up other controls, etc. If I know the text that's going into the TextBlocks, and I ...

Silverlight: TextTrimming

Hi! Is there a way to identify if TextTrimming is triggerred? for example in my first row, text is not trimmed because its only 20 characters, in my second row text are 1500 characters and it trims the text, is there a way to identify it, like IsTextTrimmed property? <TextBlock TextWrapping="Wrap" Text="{Binding test}" TextTrimming="W...

WPF Bind TextBlock to Window's Title

Hello, I have a TextBlock on my main window. I would like to bind it's text to the window's title .. eg: myWindow.Title. This has been bugging me all night, and I have Googled to death, any help is appreciated. Thanks. ...

WPF: Drawing on top of a TextBlock

I want to be able to draw on to the top of a TextBlock, and have found a way to do this, but i cannot remove the drawing once it is there. Here is the code. public class DerivedTextBlock : TextBlock { public Boolean DrawExtra { get { return (Boolean)GetValue(DrawExtraProperty); } set { SetValue(DrawExtraPrope...

In WPF how to change a DataTemplate's Textblock's text binding in code?

I have a ListBox whose ItemsSource is bound to a list of objects. The Listbox has a ItemTemplate with a DataTemplate containing a TextBlock. The textblock's Text is bound to the object's Name property (i.e. Text="{Binding Name}"). I would like to provide a radio button to show different views of the same list. For example allow a us...

Scrolling a TextBlock

Hey everyone, I have a TextBlock and a Textbox in the same location. Depending on what mode the user is in, I make one visible and the other collapsed. This is working fine, but how can I make the Textblock scrollable? I figured I should use a ScrollViewer, but I don't know why it's not working. I've tried messing around with the heigh...

Make a silverlight textblock act like a hyperlink

I'm pretty new to silverlight. I have a text block that is displayed inside a datagrid (inside a DataGridTemplateColumn.CellTemplate template to be precise). I'd like to dynamically make some of the textblocks into hyperlinks that open a new window. Is there a way to do this - so far all I can come up with is using a hyperlink button ...

Programmatically move Cursor to a TextBlock

Hello, in my application I'm opening a Window as a dialog. Inside this window, there's a TextBox called "myText". When the dialog is shown, I want the cursor to be automatically inside the "myText" TextBox, so the user can immediately enter something without having to click in the TextBox. I however have problems realising this, can som...

WPF TextBlock Negative Number In Red

I am trying to figure out the best way to create a style/trigger to set foreground to Red, when value is < 0. what is the best way to do this? I'm assuming DataTrigger, but how can I check for negative value, do i have to create my own IValueConverter? ...

WPF flush right text - possible easily?

This is a nice-to-have for our designer. She has a layout where a form title, on the top right of the form banner, is two words in English. There are several forms so the words are a little different each time. So the effect is something like: | firstword| | form| There is a fancy swoopy thing underneath this and some other...

Limiting the width of a TextBlock in Silverlight

The obvious MaxWidth gets ignored and the text in the "DisplayBox" TextBlock displays the whole text even if this text continues past the parent container controls (to the edge of the silverlight area. <win:HierarchicalDataTemplate x:Key="hierarchicalTemplate" ItemsSource="{Binding _children}"> <Border BorderThickness="0" BorderBrus...

WPF TextBlock custom wrapping : on the left and after a "."

Hello everybody, I'm trying to display a text that would be wrapped on the left and only after special characters in the string. I Hope the first part could be done in XAML, and I'm pretty sure the second part cannot. The aim is to wrap a text this way : - Original text : "Object1.Object2.Object3.Property1" - Wrapped text could be (d...

Silverlight 2 TextBlock ignores MaxWidth

I am using Silverlight 2 to dynamically add a TextBlock to a Canvas. I set the MaxWidth of the TextBlock but it ignores this value and displays a string longer than the MaxWidth value. TextBlock label=new TextBlock(); label.SetValue(Canvas.LeftProperty,Convert.ToDouble(x+3)); label.SetValue(Canvas.TopProperty, Convert.ToDouble(y + 1));...

How is it possible to stuff a Grid inside a TextBlock?

The other day I ran into the following xaml and I freaked out: <Grid x:Name="LayoutRoot"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"> <Grid> <Rectangle Fill="AliceBlue" Width="25" Height="25"/> </Grid> </TextBlock> </Grid> In other words ... how is it possible to put a Grid i...

WPF, getting value of TextBlock inside ComboBox DataTemplate

I have the following XAML: <ComboBox Height="23" HorizontalAlignment="Left" Grid.Row="6" Grid.Column="2" Name="cbo_team" VerticalAlignment="Top" Width="148" DataContext="{Binding ElementName=cbo_component, Path=SelectedItem}" SelectedIndex="0"> <ComboBox.ItemsSource> <Binding XPath="Teams/Team/@...