I want to display text in italic with Segoe UI Light font family.
I am not sure but looks like in wpf TextBlock for FontFamily Segoe UI Light, FontStyle Italic is not supported.
Is there any other control (Except RichTextBox because I want to use it for field name and value) like a label or something which I can use or am I doing something wrong.
<TextBlock x:Name="TextBlockContent"
FontSize="28"
FontStyle="Italic"
FontFamily="Segoe UI Light"
Text="Text doesn't display in italic" />
There is a Segoe UI Light Italic font (you can get it from Microsoft Typography) and it comes as part of Windows 8. However, you need to have it installed on the machine in order to be able to use it.
Specifying the base font and applying the style should work if you have the font installed.
Specifying the font explicitly will definitely work:
<TextBlock x:Name="TextBlockContent"
FontSize="28"
FontFamily="Segoe UI Light Italic"
Text="Text should display in italic" />
Related
I'm new to WPF but have coded a few basic styles. However, I am now wanting to change the caret color within the IntegerUpDown control, and am not finding a way to do this. I would like to change the color from black (default) to white. I have not custom styled anything with this control (although attempted the caret color), only set some properties of the control thus far.
<xctk:IntegerUpDown x:Name="AccelInput" Grid.Column="2" HorizontalAlignment="Left" Margin="204.342,31.549,0,0" VerticalAlignment="Top" Width="100" Height="38" Value="1" TextAlignment="Center" Maximum="5000" Minimum="1" ShowButtonSpinner="False" AllowSpin="False" Background="#FF232E3C" BorderBrush="#FF688CAF" Foreground="#FFC8E5FF" ClipValueToMinMax="True" Cursor="IBeam"/>
I'm using MahApps.Metro for my WPF app. As shown in the image below, the Forground color of a CheckBox remains default (black) if I try to change it to white.
Question: How can we change the content color to white?
None of the following XAMLs change the content's forground color. It remains default (black):
<CheckBox x:Name="chkTest" Content="Test Content" FontSize="20" Foreground="{StaticResource MahApps.Brushes.Badged.Foreground}" />
Or:
<CheckBox x:Name="chkTest" Content="Set Default" FontSize="20" Foreground="White" />
Or -as discussed here:
<CheckBox x:Name="chkTest" Content="Test Content" FontSize="20" Foreground="{StaticResource MahApps.Brushes.CheckBox.ForegroundChecked}" />
Display of the above XAMLs:
The MahApps.Metro CheckBox style has many states and triggers, which use different brushes. Overriding the Forground property does not cover all states.
However, there is a dedicated type CheckBoxHelper with many attached properties that you can use to customize every brush in each state for the content, as well as for the check mark glyph. Look for properties starting with Foreground... and CheckGlyphForeground.... There are attached properties for check mark and content background as well.
<CheckBox x:Name="chkTest" Content="Set Default" FontSize="20"
mah:CheckBoxHelper.ForegroundUnchecked="Blue"
mah:CheckBoxHelper.ForegroundUncheckedMouseOver="Green"
mah:CheckBoxHelper.CheckGlyphForegroundChecked="Red"
mah:CheckBoxHelper.CheckGlyphForegroundCheckedMouseOver="Purple"/>
WPF Italic is not applying for Japanese font. Not even when i did in VisulaSudio 2010, it is not reflecting in Designer.
<TextBox FontSize="50" FontStyle="Italic" >
Text テ「竄ャ窶
</TextBox>
I got the Solution, if i specify MS FontFamily (ex: "MS Gothic", "MS Mincho"...). Its working fine, only these fonts supporting Italic for Japanes.
<TextBox FontSize="40"
FontFamily="MS Mincho"
FontStyle="Italic" >
Text テ「竄ャ窶
</TextBox>
I recently upgraded my WPF project from .NET v3.5 to v4.0 and I'm still running into issues where all of my text is blurry. I have the following set in my main window.
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display"
From what I've read this issue was fixed in WPF 4.
Here is what it looks like using the following markup.
<TextBlock Text="Sample with TextOptions..."
FontFamily="Arial, sans-serif"
FontSize="14"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display" />
<TextBlock Text="Sample without TextOptions..."
FontFamily="Arial, sans-serif"
FontSize="14" />
While I can definetly see a difference in text, it still isn't as clear as I would expect it to be. Am I just crazy!?
I have a WPF expander control which is not rendering the expander header content when the app is run on XP machine (XP with SP3), when run on a Win7 machine the content is rendered as expected.
The expander header is a virtualised stack panel (horizontal) with a couple of text blocks inside.
When I use snoop to investigate I can see the expected text and the font colour is black - so it's not white text on a white background.
Anyone know why it would not be rendering on XP?
Header template:
<Expander.Header>
<VirtualizingStackPanel Orientation="Horizontal">
<Controls2:HighlightTextBlock Style="{StaticResource RegularTextStyle}"
Text="{Binding Name, Mode=OneWay}"
Margin="10,0,0,0"
HighlightText="{Binding RelativeSource=RelativeSource FindAncestor, AncestorType={x:Type Controls2:ViewHost}}, Path=DataContext.SearchText}"
Foreground="{StaticResource Jedi.HighlightForegroundTextBrush}"
HighlightBackground="{StaticResource Jedi.HighlightBackgroundTextBrush}"/>
<TextBlock Margin="15,0,0,0">
<Run Text="(" />
<Run Text="{Binding Id, Mode=OneWay}"></Run>
<Run Text=")"/>
</TextBlock>
</VirtualizingStackPanel>
</Expander.Header>
You should replace the VirtualizingStackPanel by a StackPanel.
According to MSDN :
The word "virtualize" refers to a technique by which a subset of user
interface (UI) elements are generated from a larger number of data
items based on which items are visible on-screen. Generating many UI
elements when only a few elements might be on the screen can adversely
affect the performance of your application. The VirtualizingStackPanel
calculates the number of visible items and works with the
ItemContainerGenerator from an ItemsControl (such as ListBox or
ListView) to create UI elements only for visible items.
So in this case, as there are few items inside your panel, it is not needed.