textblock

Highlight Search TextBlock

心已入冬 提交于 2020-03-18 15:38:57
问题 My goal is to create a custom TextBlock control that has a new dependency property, SearchText. This property will contain a regular expression. All occurrences of this regular expression in the text of the TextBlock will be highlighted using a custom style (another DP). My current implementation involves clearing all of the Inline objects in the TextBlock's InlineCollection. I then fill the TextBlock with runs for unhighlighted text and runs for highlighted text with the style applied (this

How to set textblock or label with resizable font size in WPF?

匆匆过客 提交于 2020-02-01 05:06:10
问题 In WPF, if i put any controls in grid, if i resize the grid, it automatically resizes all the controls in it.But in label or textblock or any other text elements, all the control sizes will change but font size remains same, it will not change. If font has to change as per grid size, What should be done? 回答1: You can achieve this by using a ViewBox . It will transform (not resize) your font (well, the control) depending on the control size. Look at this here for more information; <Viewbox

How to set textblock or label with resizable font size in WPF?

試著忘記壹切 提交于 2020-02-01 05:04:00
问题 In WPF, if i put any controls in grid, if i resize the grid, it automatically resizes all the controls in it.But in label or textblock or any other text elements, all the control sizes will change but font size remains same, it will not change. If font has to change as per grid size, What should be done? 回答1: You can achieve this by using a ViewBox . It will transform (not resize) your font (well, the control) depending on the control size. Look at this here for more information; <Viewbox

WPF Textblock text does not change dynamically on combobox selected item

自古美人都是妖i 提交于 2020-01-25 10:40:24
问题 I have a MVVM app. In main WPF window I have a combox and a textblock among other controls. When I select a value from the combobox, the textblock text should change its text value dynamically according to the item selected in the combobox (depending on the id of the selected item in combobox). My problem is that when I select a item in the combobox, textblock text does not change, it always have the default value. Any ideas how to solve this? I want to do this using xaml only. Model : public

Bind Textblock text to 2 different properties

我怕爱的太早我们不能终老 提交于 2020-01-24 20:57:57
问题 I have a binded treeview that displays one of the properties (namely, the displayname) of the treeviewitem (which are custom viewmodel's of an object). Here is the associated xaml: <local:ExtendedTreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}"> <TextBlock Text="{Binding OrganDisplayName}" > </TextBlock> </HierarchicalDataTemplate> </local:ExtendedTreeView.ItemTemplate> What I want is to be able to display another property next to the display name in

How to represent Line Break or new line in silverlight textBox

爷,独闯天下 提交于 2020-01-22 05:18:04
问题 I am having hard time to match Special characters set in Silverlight. I only on the following: To represent a LineBreak in Silverlight TextBlock: use : > lineBreak < But What do I use to represent a New Line or LineBreak In Silverlight TextBox?? Example : I want this one line mag : This is line one. This is line two into this : This is line one. This is line two. it seems this \r\n is not working. This is line one \r\n 回答1: The bottom line at the top <TextBox Text="This is line one! This is

Spacing added when switching control template dynamically

Deadly 提交于 2020-01-16 03:50:09
问题 I've implemented switching of TextBox with TextBlock on clicking. My goal was to show ... when the text becomes wider than the TextBox width I've followed this answer to come up with a solution. This is my current code: <TextBox x:Name="TextBox" Height="24" Width="300" Cursor="Hand" BorderThickness="0" Background="White" VerticalAlignment="Center" Text="{Binding MyCustomText}"> <TextBox.Style> <Style TargetType="TextBox"> <Setter Property="Background" Value="Yellow" /> <Style.Triggers>

Clicking on a TextBlock in WPF richtextbox

故事扮演 提交于 2020-01-14 13:11:26
问题 I have a flowdocument like this: var mcFlowDoc = new FlowDocument(); var para = new Paragraph(); para.Inlines.Add(textBlock1); para.Inlines.Add(textBlock2); para.Inlines.Add(textBlock3); mcFlowDoc.Blocks.Add(para); richTextBox1.Document = mcFlowDoc; and I need an event to trigger on mouse click on a textblock: <RichTextBox Margin="10,10,230,12" Name="richTextBox1" FontFamily="Simplified Arabic" FontSize="16" IsReadOnly="True" IsReadOnlyCaretVisible="False" ForceCursor="False" FlowDirection=

Binding in TextBlock doesn't work in WPF

大兔子大兔子 提交于 2020-01-10 05:47:08
问题 I want to dynamically change TextBlock text in my Class. XAML-Code : <TextBlock Name="Footer_text" Text=""/> C# : string footerMainMenuText = "Setting"; Binding set = new Binding(""); set.Mode = BindingMode.OneWay; set.Source = footerMainMenuText; Footer_text.DataContext = footerMainMenuText; Footer_text.SetBinding(TextBlock.TextProperty, set); I checked last line, and the Footer_text.Text is set correctly. ( Footer_text.Text="Setting" ), but TextBlock in my application doesnt show "Setting".

In wpf Clear ListBox items at Runtime

北战南征 提交于 2020-01-06 23:49:46
问题 I am using wpf listbox, i cannot able to clear the list when am calling the reload data function, i just want to reload new data at runtime,while page loading it loads the data correctly, when i refresh the new data is fetched in itemsource i can see that in debug mode, but no new data in listbox, old data remains in the list, i cant even clear, when i call list.items.clear(), i tried lot ways, is there any problem in my XAML binding, the following is my code. XAML: <ListBox ItemsSource="