textblock

Display images in TextBlock (WPF)

故事扮演 提交于 2019-12-30 03:04:08
问题 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> </ListBox> Now I would like to be able to put images (like graphical smileys) into the displayed message text. Is there any way to achieve this using TextBlock (or any other standart component) or do

Programmatically determining max fit in textbox (WP7)

无人久伴 提交于 2019-12-29 06:25:14
问题 I'm currently writing an eBook reader for Windows Phone Seven, and I'm trying to style it like the Kindle reader. In order to do so, I need to split my books up into pages, and this is going to get a lot more complex when variable font sizes are added. To do this at the moment, I just add a word at a time into the textblock until it becomes higher than its container. As you can imagine though, with a document of over 120,000 words, this takes an unacceptable period of time. Is there a way I

Visible line count of a TextBlock

笑着哭i 提交于 2019-12-29 06:18:47
问题 If you set TextWrapping to "Wrap", a WPF TextBlock can have several lines of text. Is there a "clean" way to get the number of lines of text? I considered looking at the desired height and dividing it by an estimated height of each line. However, that seems quite dirty. Is there a better way? 回答1: One thing about WPF that's very nice is that all of the controls are very lookless. Because of this, we can make use of TextBox, which has a LineCount property (Why it's not a DependencyProperty or

WPF read Checkbox.Content

笑着哭i 提交于 2019-12-25 04:04:16
问题 I have a couple of CheckBoxes with a TextBlock as content. Now I want to read out the TextBlock.Text from each Checkbox. If I read out the content like checkBox.Content.ToString(); I only get System.Windows.Controls.TextBlock which kinda makes sense. I also tried to create a new TextBlock and give it the content but it didn't work. TextBlock _tempTBL = new TextBlock(); _tempTBL = checkBox.Content; Any help is much appreciated. 回答1: var _tempTBL = (TextBlock) checkBox.Content; //Get handle to

Windows Phone 7 - TextBlock Text binding to ViewModel not returning anythinig

对着背影说爱祢 提交于 2019-12-25 03:32:55
问题 I have built a view model and the listbox binds to the ObervableCollection, but a textbox I am using for a temp url wont bind and return data. I am not getting any errors either on compile or run ViewModel: public class HomepageModel:INotifyPropertyChanged { public TextBlock bgrImg{get;set;} public ObservableCollection<MenuItem> menu {get; private set;} public HomepageModel() { this.menu = new ObservableCollection<MenuItem>(); } public void Load() { bgrImg = new TextBlock(); bgrImg.Text = "

TextBlock is Cutting Text in Windows Phone

廉价感情. 提交于 2019-12-25 03:17:07
问题 In my WP8 project textblock is cutting text unexpectedly. How can I solve it? I have used VerticalAlignment Strecth or Height auto in scrollviewer but they have not solve it. And my xaml, I am using one of these stackpanels : <ScrollViewer> <Grid> <StackPanel x:Name="stackNormal" Visibility="Collapsed" VerticalAlignment="Top" Background="Transparent"> <ListBox Name="ImageList" ItemsSource="{Binding Summary.Text , Converter={StaticResource ImageFromRssText}}" ScrollViewer

WinRt TextBlock with single space width

五迷三道 提交于 2019-12-25 02:25:32
问题 I'm trying to make a text on path element. To accomplish this I split original text to single characters and for each character create new TextBlock and count it's width after measurement. The problem is, that when a TextBlock contains only a single space it's width is 0, it seam's space is being trimmed. How do I prevent trimming spaces? Or maybe there's a better suggestion? Thanks a lot. 回答1: If you want to place a space on path - you don't really need to display a TextBlock there. If you

Textblock dyanmic placement WPF

烂漫一生 提交于 2019-12-25 00:38:19
问题 I have a text data. I would like to place the data dynamically to a certain point [Absolute point, it may be (0,0) (10,10) or (100,100)]. Here the problem comes. My requirement is text block's center point should be the base point. How to make it and place it directly on the canvas? [Which means align the absolute point and center point of the textblock]. Because in winforms we can set the alignment property and place it directly. Please check this question .It describes how to move the

How can I convert this TextBlock fade-in trigger to a Style

妖精的绣舞 提交于 2019-12-24 12:30:33
问题 This XAML makes text fade in when it appears. I would like to put this functionality into a Style. However, but what do I put in for the "TargetName" since the style doesn't know which element is going to be using it? How can I convert this fade-in effect to a style? <TextBlock Name="Message" Text="This is a test."> <TextBlock.Triggers> <EventTrigger RoutedEvent="TextBlock.Loaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="Message" Storyboard.TargetProperty="

WPF C# get the size and position of inline element of a TextBlock

依然范特西╮ 提交于 2019-12-24 11:23:28
问题 I use this example ( https://siderite.dev/blog/how-to-draw-outlined-text-in-wpf-and.html ) for add outline to a text in a TextBlock. However this example don't support Inlines. I try to add this ability modifying the OnRender and I iterate the Inlines collection to build a Geometry for each Inline block. The problem is that I need to get the position and size of the inline block in the TextBlock instead of those of the whole text in the TextBlock. This is the source code that I have modified.