WPF 4 blurry font - wpf

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!?

Related

Only some Font Awesome glyphs display in WPF

I am attempting to use Font Awesome in a WPF app. It half works. That is, some glyphs are picked up and show, others show a rectangle.
I'm following guides correctly, I think, but something is going wrong!
Here's a code snippet
<Window.Resources>
<FontFamily x:Key="FontAwesomeRegular">Fonts/Font Awesome 5 Free-Regular-400.otf#Font Awesome 5 Free Regular</FontFamily>
<FontFamily x:Key="FontAwesomeBrands">Fonts/Font Awesome 5 Brands-Regular-400.otf#Font Awesome 5 Brands Regular</FontFamily>
<FontFamily x:Key="FontAwesomeSolid">Fonts/Font Awesome 5 Free-Regular-400.otf#Font Awesome 5 Free Solid</FontFamily>
</Window.Resources>
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="" HorizontalAlignment="Left" Foreground="Red" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" FontSize="100"/>
<TextBlock FontFamily="{StaticResource FontAwesomeSolid}" Text="" HorizontalAlignment="Left" Foreground="Red" Margin="0" TextWrapping="Wrap" VerticalAlignment="Center" FontSize="100"/>
</StackPanel>
</Grid>
The fonts are installed in a Fonts directory
And Marked as Resource
And this is what it shows on the screen
You can see that the first icon xf15c; displays as expected but the second one xf15a; does not. Generally, most do not display.
Why?
If you open the .otf file, you can see the name of the font. This is what you need to use to the FontFamily resource, without the file extension.
Try the following code:
<FontFamily x:Key="Icons">pack://application:,,,/{YOUR PROJECT NAME};component/Fonts/#Font Awesome 5 Free Solid</FontFamily>

MahApps Progress Indicator not stretching to content

I have a MahApps progress indicator declared like this:
<Controls:ProgressIndicator ProgressColour="{StaticResource AccentColorBrush}" Width="600" Height="20" VerticalAlignment="Top" HorizontalAlignment="Stretch"
Visibility="{Binding ElementName=Self, Path=DataContext.ShowProgress, Converter={StaticResource b2v}, FallbackValue=Visible}"/>
And for some reason the indicator bars do not stretch the size of the control. It only fills about 20% of the width. (I can't show a picture as my reputation is too low).
Has anyone experienced this before?
Cheers
Edit
The indicator is on a stackpanel declared like this:
<StackPanel Grid.Column="2" Grid.ColumnSpan="6" Orientation="Vertical">
Update:
In the latest version from nuget or Github ProgressIndicator seems to be removed(cos it was buggy).
Pull request that removed the control early this year
This release, again, contains some breaking changes. We try to break things now rather than later, when we release version 1.0 (which is hopefully soon).
A quick overview:
ProgressIndicator is now removed, as it wasn't working as expected. Use MetroProgressBar with IsIndeterminate = True instead, which should give a much smoother experience.
I just tried the sample with
<Controls:MetroProgressBar Width="300"
Margin="0, 10, 0, 0"
Foreground="{DynamicResource AccentColorBrush}"
IsIndeterminate="True"
Maximum="100"
Minimum="0" />

WPF Scrollviewer on touch screen tablet

I'm writing a WPF application that is going to run on a full windows 8 touchscreen tablet (not RT).
However touch scrolling doesn't seem to be working. So I'm wondering if it's something I'm doing wrong or if it's even possible?
So, I have a WPF window with a scrollviewer. Within that scrollviewer I have a StackPanel which has loads of textblocks within it. See below:
<ScrollViewer>
<StackPanel>
<TextBlock Text="Row 1" />
<TextBlock Text="Row 2" />
<TextBlock Text="Row 3" />
<TextBlock Text="Row 4" />
<TextBlock Text="Row 5" />
<TextBlock Text="Row 6" />
....
<TextBlock Text="Row 50" />
</StackPanel>
</ScrollViewer>
Now using the touchscreen I try to scroll the contents but it doesn't move. I can only scroll the contents using side scollbar which is not how I want this to work. Is it possible to get touch scrolling working with WPF? I'd also want to do the same with the grid.
Thanks in advance.
I'm using Visual Studio/Blend 2012.
You can enable scrolling with the PanningMode property like this:
<ScrollViewer PanningMode="Both"></ScrollViewer>.
See: MSDN
Mouse support
If you want to implement this behavior with the mouse, please read this article.

VB.NET WPF Ribbon 2010 .net 4.0 does not work 3.5 does

I just installed Microsoft Ribbon for WPF 2010 on 2 different windows 7 boxes. If I make a .net 3.5 project it works fine but a .net 4.0 it does not.
I can load the sample ribbon application and it works but when I drag the ribbon controls over they just make a transparent box.
I notice it does not make the XAML correct. Here is the code, 4.0 on top then 3.5 below it. Is there some setting or option I need to change?
<ribbon:Ribbon Height="136" HorizontalAlignment="Left" Name="Ribbon1" VerticalAlignment="Top" Width="618" />
<ribbon:RibbonGroup Height="100" HorizontalAlignment="Left" Margin="72,36,0,0" Name="RibbonGroup1" VerticalAlignment="Top" Width="200" />
<ribbon:RibbonTab Grid.RowSpan="2" Height="100" HorizontalAlignment="Left" Margin="96,50,0,0" Name="RibbonTab1" VerticalAlignment="Top" Width="200" />
<ribbon:RibbonGroup Grid.RowSpan="2" Height="100" HorizontalAlignment="Left" Margin="156,80,0,0" Name="RibbonGroup2" VerticalAlignment="Top" Width="200" />
<my:Ribbon Height="139" HorizontalAlignment="Left" Name="Ribbon1" VerticalAlignment="Top" Width="503">
<my:RibbonTab Header="Tab" Name="RibbonTab1">
<my:RibbonGroup Header="Group" Name="RibbonGroup1">
<my:RibbonButton Label="Button" Name="RibbonButton1" />
</my:RibbonGroup>
</my:RibbonTab>
</my:Ribbon>
The Microsoft Ribbon control (Oct 2010 release) is a joke. They got it working..."mostly" and then left it full of bugs without fixing them. "It will work properly in the next version of Visual Studio"...um, okay.
I tried to use it and was constantly frustrated. DevComponents has a pretty solid Ribbon control for WPF. I recommend it. But I still have a couple of issues with that one, too.
Good luck!

Silverlight: why png-image is not displaying?

In Silverlight 4 application there are few images, both are displayed correctly in design mode, one is displayed correctly in run-time also:
<Image Height="180" Width="149" Source="../Picts/Field.png" />
Another one is not displayed in run-time:
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Visibility="{Binding SquadSavedVisibility, Mode=OneWay}">
<Image Source="..\Picts\ok.png" Width="16" Height="16" />
<TextBlock Text=" It is saved" Foreground="Green"/>
</StackPanel>
Why? And how to get it displayed?
Any thoughts are welcome. Thanks.
It's all in your slashes, VS Design time doesn't mind you using "..\Picts\ok.png", but Silverlight runtime wants to see "../Picts/ok.png". In other words, your slashes matter.
I had a similar problem with images showing in design-time, but not at runtime. Mine was using a pack URI so I wanted to post that fix as well:
Does not work at runtime, does work at design-time:
<Image Source="mydllname;component/Images/logo.png" />
Works at both design and runtime:
<Image Source="/mydllName;component/Images/logo.png" />
Note the extra '/' before the Pack URI starts.
You can try to hook into the Image.ImageFailed Event. For examples and more explanation you look into this page:
http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed%28v=VS.95%29.aspx

Resources