textblock

Concatenated Text in TextBlock DataTrigger

折月煮酒 提交于 2019-12-12 05:53:43
问题 I try to work with a concatenated text in the setter of a textblock. textblock looks like that: <TextBlock> <Run Text="{x:Static languages:visuTexts.Lenght}" /> <Run Text="A [LA]"/> <TextBlock.Style> <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}"> <Style.Triggers> <DataTrigger Binding="{Binding Product.DiameterA}" Value="0"> <Setter Property="Text" Value="concatenated text here" /> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> i want to

Foreground colour of textblock based on position of part of the letter

社会主义新天地 提交于 2019-12-12 03:35:52
问题 A Mars bar challenge at work is that using Xaml only, make the following text of a text block gray by default. But, from half way through the letter "e" and to half way to last character "1" make the colour red. The text is "Item 1". So, "I" and "t" all gray, but the first half of "e" red, all of "m" red and then half of "1" red and the last half of "1" gray. I have no idea about this one. 回答1: Were you thinking about something like this? <TextBlock FontSize="72"> <Run Foreground="Gray" Text=

How can I extend a TextBlock to display Outlined Text?

 ̄綄美尐妖づ 提交于 2019-12-12 03:26:51
问题 My question relates to this question. This question is quite dated, and the answer more so and it feels like it is lacking somewhat. The user created a control from scratch that is lacking somewhat, but the biggest point is that it doesn't feel like it should be necessary ( to me, at least ) to create an entirely new control in order to have a TextBlock that can support stroked ( outlined ) text. I'm trying to extend the TextBlock control by providing a Brush property and a double property. I

Multiline WPF textblock: different alignment for lines

你离开我真会死。 提交于 2019-12-12 03:08:42
问题 Is that possible to set different horizontal alignment for different lines of multiline textblock? For example, I want to center header of my text, but main text I want to align by left side. I'd not want to use several textblocks for this issue. Thanks. 回答1: I do not think you can get what you are looking for using the TextBlock control, this because the Inline elements that you can add in your TextBlock does not allow you to control the horizontal alignment (line by line). Anyway I do not

Why doesn't my text block style get applied?

一世执手 提交于 2019-12-12 02:24:43
问题 I have a style created in my windows resources area: <Style TargetType="TextBlock"> <Setter Property="TextTrimming" Value="CharacterEllipsis"/> </Style> I thought this meant that all text blocks would have this style, so when I create my list view column: <GridViewColumn> <GridViewColumnHeader Content="Source"/> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Source, Mode=OneWay}" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> The ellipsis style is

WPF TextBlock highlight certain parts based on search condition

这一生的挚爱 提交于 2019-12-12 01:57:05
问题 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 mind that it may highlight several different Run objects at a time). I have tried this example http://blogs.microsoft.co.il/blogs/tamir/archive/2008/05/12/search-and

Remove the C# TextBlock inlines elements padding

为君一笑 提交于 2019-12-11 12:55:53
问题 About TextBlock UIElement in C#, we could add several Run object into it, which will be appended to inlines property. That's one way we show several pieces of text with different format(font, size and etc) in one TextBlock . My question is: when I add, such as, two Run object into one TextBlock , there exist a padding between each Run object. For example, I add "12" and "34" Run objects, and finally they will be shown as "12 34" in the view. But what I need is they should be connected

WPF - TextBlock - Cannot override OnRender

∥☆過路亽.° 提交于 2019-12-11 11:52:53
问题 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 advance. 回答1: In WPF you normally work with styles or Control templates to change the appearance of a control. You can download templates for all controls from

When text wraps within TextBlock, ActualHeight is incorrect

牧云@^-^@ 提交于 2019-12-11 10:31:13
问题 I have a TextBlock with a Border around it that's inside of a Canvas that I'm using to animate it as part of a custom control. The block slides in from the bottom of the screen over the top of the image. I'm trying to use the ActualHeight of the TextBlock to determine how far to move it onto the page, but when there is so much text that it wraps to two lines, the ActualHeight returns the same size as though there was a single line. TextBlock: <DataTemplate DataType="{x:Type contentTypes

WPF, how to override an application wide style on textblocks on specific places

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:52:02
问题 I have a style xaml resource dictionary which is added in Application.xaml. In that style file I specify that all textblocks should have the foreground white. The problem is that this will change the combobox items foreground to white in a usercontrol I have in the same application. I want the items to have a black foreground in all or only this one combobox. I'm having big troubles making that happen. This is my global style for textblocks: <Style TargetType="{x:Type TextBlock}" > <Setter