textblock

How to add TextBlock text value from database object value

僤鯓⒐⒋嵵緔 提交于 2019-12-13 08:36:06
问题 I'm working on WPF application which has one Window.xaml where I'm using dataGrid which is filled from Database (MSSQL 2008R2), In that dataGrid I'm loading orders from my Database. I'm also grouping my orders by numberOfOrder, and its possible to expand them or to collapse them, in case there will be many orders at same time. Anyway, inside of my expander Is DockPanel, which has textBlock there, I used that textBlock to display number of each order from database, but I am wondering how could

Change TextBlock foreground color using background color

核能气质少年 提交于 2019-12-13 05:15:34
问题 In my WPF application, I have to keep on updating TextBlock background based on user conditions. TextBlock style is defined in App.xaml. If the background is too dark (Green/Blue) I want to set the foreground to white else black. How can I achieve this? I explored following two options: Via DataTriggers: In App.xaml: <Style TargetType="TextBlock"> <Setter Property="FontSize" Value="14"/> <Setter Property="FontStyle" Value="Normal"/> <Style.Triggers> <DataTrigger Binding="{Binding

WPF TextWrapping on white spaces

谁都会走 提交于 2019-12-13 04:49:26
问题 I am using a TextBlock in WPF, on which I want to use TextWrapping, What I have done in XAML is as follows. <TextBlock TextWrapping="Wrap" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Margin="5,5,5,5"> <TextBlock.Text> This is just a test. This is just a test. </TextBlock.Text> </TextBlock> When I run this code it shows output like this This is just a test. Th is is just a test. But I only want wrapping on white spaces like This is just a test. This is just a test. I am unable to find why

C# MVVM How to add Command to TextBlock

核能气质少年 提交于 2019-12-13 04:28:02
问题 I'm trying to add a command to my TextBlock but haven't had any success yet. I tried following: In XAML I've got a ItemsControl where I'm adding my TextBlocks : <ItemsControl ItemsSource="{Binding CellCollection}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Background="{Binding Path=CellBackgroundColor}"> <TextBlock.InputBindings> <MouseBinding Command="{Binding TestCommand}" MouseAction="LeftClick"/> </TextBlock.InputBindings> </TextBlock> </DataTemplate> </ItemsControl

How to handle TextBlock.KeyDown event, when TextBlock is a part of UserControl?

≡放荡痞女 提交于 2019-12-13 03:57:25
问题 I have this simple UserControl : <UserControl x:Class="WPFTreeViewEditing.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <TextBlock Text="Hello, world!" KeyDown="TextBlock_KeyDown" /> </Grid> </UserControl> I

How to set current CultureUI via XAML binding

对着背影说爱祢 提交于 2019-12-12 19:56:46
问题 I have a TextBlock bound to a string. I want the string to be displayed in current UI culture of the application. I want to do this in XAML. The text block is simple like below. <TextBlock Text="{Binding Path=Text}"/> 回答1: You need to set the FrameworkElement.Language property. The easiest way to do that for the whole application is to override the property metadata in the App class static constructor: public partial class App : Application { static App() { FrameworkElement.LanguageProperty

Can I wrap the Content/text value of a RadioButton in WPF?

无人久伴 提交于 2019-12-12 11:17:20
问题 I have some XAML: <StackPanel Orientation="Horizontal"> <TextBlock x:Name="KeyLWP" TextWrapping="Wrap" MaxWidth="120">A Letter or Word or Phrase </TextBlock> <StackPanel> <RadioButton x:Name="rdbtnCandidateVal1" Content="Two wrongs don't make a Wright Brothers Grimm was the Thingamabob Dylan Thomas Jefferson Airplane"> </RadioButton> ...where, with a long string assigned to a RadioButton's Content, it simply falls off the edge of the earth. How can I get it to wrap, if necessary, as I can

Multiple Run elements in WPF Style setter

安稳与你 提交于 2019-12-12 11:15:41
问题 Is it possible in XAML to define multiple Run 's inside a Style setter? The following has two Run 's defined and fails: The property 'Value' is set more than once. <TextBlock> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}"> <Setter Property="Text"> <Setter.Value> <Run Text="{Binding SelectedItem.iso}"/> <Run Text="{Binding SelectedItem.value}"/> </Setter.Value> </Setter> <Style.Triggers> <DataTrigger Binding="{Binding SelectedItem.type}" Value={x:Null}"> <Setter Property="Text"

WPF: how to write text in a different direction?

跟風遠走 提交于 2019-12-12 11:06:11
问题 I need to write text in the orientation specified for the image below. The fact is that I saw some examples around here by using a textblock and rotating the angle of the control using "RenderTransform", but this is not what I really need. I tried to do it using an image but it doesn't fit very well... so I really don't know how to solve it. If you look at the image beside you can see that the text is written from bottom to top and the line below the text is in the right of the screen. This

How would I databind a Paragraph to a TextBlock?

南笙酒味 提交于 2019-12-12 08:54:47
问题 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 solution. Edited question to focus on what I really need to do. 回答1: Here's an example using a nested ItemsControl. Unfortunately, it will make one TextBlock per