You need a converter: public class StringPropertyContainsThomasConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if(value != null) { if(value.ToString().Contains("Thomas")) return Brushes.Blue; //replace with whatever color you want } return Brushes.White; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw...
According to the documentation InlineCollection contains InsertBefore, InsertAfter, Insert, RemoveAt
I have find a workaround by using converter: <ListBox x:Name="actionList" Height="150" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MouseMove="ListBoxMouseMove" ScrollViewer.VerticalScrollBarVisibility="Visible" SelectionMode="Extended" Style="{StaticResource CustomListBoxStyle}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock x:Name="textBlock" Width="235" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="11" Text="{Binding DisplayText, Converter={StaticResource...
Because TextBlock is the only control where you don't set manually the initial value as you do with Background against Grid and Fill against Ellipse. If you want Trigger to be able to overwrite default value you need to bring it into Style as Setter <Grid Width="200" Height="100" > <Grid.Style>...
You could simply put both TextBlock at the same Grid Cell and set their Visibility to true/False based on the selected Button : <TextBlock x:Name="ShowVlanTb" Visibility="Hidden" TextWrapping="Wrap" Height="350" Text="{Binding ShowVlan}" Grid.Row=1 Grid.Colomn=2 /> <TextBlock x:Name="ShowRoutingTb" Visibility="Hidden" TextWrapping="Wrap" Height="350" Text="{Binding ShowRouting}" Grid.Row=1 Grid.Colomn=2> /> and on the button Click event handler...
wpf,combobox,vertical-alignment,textblock
A TextBlock should not have a height but its container should instead. If you want to set the background color for your TextBlock then wrap your TextBlock in a Border or a Grid and set the height on them instead. Like <Grid Height="50> <TextBlock VerticalAlignment="Center" Text....../> </Grid> ...
If you want the image to remain its size... simply get rid of the grid rows and throw the TextBlocks into a vertical StackPanel. If you want to resize your image so that it has the same height as the 3 TextBlocks... you can bind the Height of the Image...
xaml,windows-phone-7,windows-phone-8,alignment,textblock
I would personally use a Grid as it is far more flexible than StackPanel and deals with different screen sizes much better. something like below <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <TextBlock Text="Cant send: message" FontFamily="Segoe WP SemiLight" FontSize="18" Margin="0,0,-1,0" TextWrapping="Wrap"/> <TextBlock Text="1:14a" Grid.Column="1" FontFamily="Segoe WP SemiLight" TextWrapping="Wrap" FontSize="18"...
I'm guessing that either LongDescription or CodeNumis is a read-only property (doesn't have public setter). You need to change binding to be one way for all read-only properties that you use in Run <Run Text="{Binding LongDescription, Mode=OneWay}"/> ...
A Button control for this was a better choice. You can pass the alphabet as the TAG property of the Button control. Following image shows Button B being pressed (just for example). You can always add your own logic to that. Code behind C# file protected override void OnNavigatedTo(NavigationEventArgs e)...
wpf,xaml,button,alignment,textblock
You need to add HorizontalContentAlignment="Stretch" to Button in order for contents to take up full space. After that, to make space between text and button borders, just add two more grid columns at first and last position. XAML: <UserControl x:Class="MyNamespace.MyClass" 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"...
c#,wpf,xaml,wpf-controls,textblock
You should override metadata in HighlightTextBlock static constructor, as such: public partial class HighlightTextBlock : TextBlock { static HighlightTextBlock() { DefaultStyleKeyProperty.OverrideMetadata(typeof(HighlightTextBlock), new FrameworkPropertyMetadata(typeof(HighlightTextBlock))); } } If you do not do this, by default, the HighlightTextBlock will try to find implicit style for TextBlock, not HighglightTextBlock....
c#,xaml,windows-phone-8,textblock,capitalize
You can use a converter as follows: <TextBlock Margin="5,0,0,0" FontSize="20" Text="{Binding name, Converter ={StaticResource myConverter}}" /> Specific information on how to implement a converter can be found here. You can essentially perform any operation you like on the text. I actually like Humanizer to do these type of text conversions....
Using EventTrigger and Color Animation you can change color of TextBlock Background color on MouseDown or MouseLeave xaml code <StackPanel> <StackPanel.Resources> <Style TargetType="TextBlock"> <Style.Triggers> <EventTrigger RoutedEvent="MouseDown"> <BeginStoryboard> <Storyboard> <ColorAnimation Storyboard.TargetProperty="Background.Color" From="Yellow" To="Blue" Duration="0:0:0.1"></ColorAnimation> </Storyboard> </BeginStoryboard> </EventTrigger>...
With large data, you are almost always better off if you paginate the results. This is the approach google takes with their search results. You get millions but only a fraction are on the first page. Microsoft gives you the tools to accomplish this - FlowDocument You can very quickly...
wpf,xaml,windows-phone-7,windows-phone-8,textblock
All you have to do is to replace StackPanel with Grid. <DataTemplate> <Grid Margin="25,20" Background="#FF616464" Width="Auto"> <TextBlock Text="{Binding title, Mode=TwoWay}" FontSize="40" Margin="20,20" Foreground="White" TextAlignment="Left" TextWrapping="Wrap" FontStyle="Normal" FontFamily="Segoe UI"/> </Grid> </DataTemplate> Result: ...
Simplify your grid - and place everything inside it. This way everything will center horizontally and vertically within the same visual context. <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="153" Width="155"> <DesignInControl:CircularProgressBar HorizontalAlignment="Center" VerticalAlignment="Center" SegmentColor="#FF878889" StrokeThickness="10" Percentage="100" /> <DesignInControl:CircularProgressBar HorizontalAlignment="Center" VerticalAlignment="Center" SegmentColor="#FF5591E8"...
c#,wpf,triggers,datepicker,textblock
So. I've found the Problem. The Problem is, when a Property is set in the Object self, then it can't be overridet. When you need a Default-Value and a Trigger, then you must define the Default-Value in the Style too. Example: <TextBlock> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Text" Value="{x:Null}" /> <Style.Triggers>...
I found one simple solution. Although it works in this case, I'm not sure how generally usable or good it actually is. Anyway, I set Width of the restricted TBlock to 1. It shouldn't be 0 because then the optimisation code in its layout methods might bypass some of its...
xaml,radio-button,textblock,textwrapping
You have some options, you could go make it do so in the Radio Button Style Template so it applies to all of them, or at the instance level just a quick; <RadioButton> <RadioButton.Content> <TextBlock Text="Wrap My Content Pretty Pretty Please" TextWrapping="Wrap"/> </RadioButton.Content> </RadioButton> Or there's other options also, let...
Try this : <Border BorderThickness="5" BorderBrush="#FF30333A" Width="{Binding Width}" background="#FF1C2125" Height="{Binding Height}"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Path Grid.Row="0" HorizontalAlignment="Left" Name="starPath" Fill="Gray" Data="M 9,0 L 7,6 L 0,6 L 6,11 L 4,17 L 9,12 L 14,17 L 12,11 L 18,6 L 11,6 L 9,0"/> <TextBloc Grid.Row="1" Text="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"...
wpf,dependency-properties,textblock
Make the inline_MouseEnter and inline_MouseLeave methods non-static and attach them to your Runs like this: inline.MouseEnter += tb.inline_MouseEnter; inline.MouseLeave += tb.inline_MouseLeave; Even better would be to make the whole PropertyChangedCallback non-static and then write the dependency property declaration like this: public static readonly DependencyProperty InLineTextProperty = DependencyProperty.Register("InLineText", typeof(string), typeof(CustomTextBlock), new...
If you use a label instead of a TextBlock you can arrange the text to be central.
The Run may be a (direct or indirect) child element of one of the Inlines, and hence not itself be an element of the top-level Inline collection. In the following XAML, the Inlines collection contains two elements, a Run and a Bold. The other Run is a child of the...