charri / font-awesome-wpf Goto Github PK
View Code? Open in Web Editor NEWFontAwesome controls for WPF+UWP
License: MIT License
FontAwesome controls for WPF+UWP
License: MIT License
I'd like to use FontAwesome as a regular font resource, alike what's been done in this article or this SO thread.
Thus I was wondering if the installed Nuget package also includes the font as a resource. I checked the package folder and I can only wonder if FontAwesome.WPF.dll embeds the resource.
TY
Fixed-width for TextBlock based FontAwesome option.
http://fontawesome.io/examples/#fixed-width
While data Loading process, by making iconObj.spin = true and providing spin duration, Icon starts spinning.
later at completion i am trying to replace spinning icon by check icon and making iconObj.spin = false. But check icon is getting displayed in random angles. and i am not able to reset that angle.
Attached images for reference, anyone can validate this, if there is a way to reset the angle please let me know.
(consider this as a spinning icon)
I want to use the refresh spinning icon but I want to set its color to white.
I tried editing the code around but failed to implement it. here's my code it would be awesome if there was a color attribute.
<fa:ImageAwesome Icon="Refresh" Spin="True" Height="48" Width="48" />
Description: The assembly 'lib\FontAwesome.WPF.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.
Solution: Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning.
With .NET Core 3.1, WPF is now supported on the much lighter CoreFx runtime. This is still limited to running on Windows, though this support will be maintained for the forseeable future.
We have two options for implementation:
NetFx 4.5.0 is compatible with NetStandard 1.1. NetFx 3.x is not compatible with NetStandard at all. As such, to maintain current support, we could multi-target 4.5.0 and NetStandard 1.1. This change should theoretically be a one-line change.
Option two is to add a new project targeting NetStandard 2.1, as this is compatible with CoreFx 3.1 and future releases (.NET 5+), however we lose all support for NetFx.
I understand that with the numerous legacy WPF apps, maintaining backwards compatibility is a priority, and as such I would personally recommend option one. This would allow us to target NetFx 4.5.0 and later, including all past, present, and future versions of CoreFx.
The most ideal situation is to do both - NetStandard 1.1 to maintain backwards compatibility and NetStandard 2.1 to support newer releases and even eventually .NET 5, but if this is decided upon it's likely best to split this into two issues.
I do not know the state of UWP on NetCore, since it's not a technology that I am familiar with using, though it may be worth looking into implementation there as well.
Please update the package to the newest Font Awesome. :) https://fontawesome.com/
I tried the FontAwesome.UWP.
Unfortunately it does not get a style:
<Style x:Name="stlFontAwesome" TargetType="fa:FontAwesome">
<Setter Property="FontSize" Value="40"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
And then:
<fa:FontAwesome x:Name="iPause"
Icon="Pause"
Grid.Column="0"
Style="{StaticResource stlFontAwesome}"
Visibility="Collapsed"
/>
Nor alignment or a font size.
In addition, it's invisible in design mode, before program running.
Icon fa-folder-open-o
is listed under FolderOutlinepenOutline
. Note the missing "O" in "Open."
Hi @charri
Maybe I used it wrong but to my understanding the FontAwesome.WPF.Converters.ImageSourceConverter which inherits from MarkupExtension cannot be used as such since its ProvideValue Function returns a this refrence.
Would it be possible to adapt it a little bit so it would be usable as a MarkupExtension ?
Right now I use this as a MarkupExtension :
`
public class ImageSourceFromFont : MarkupExtension
{
private FontAwesomeIcon _icon;
private Brush _brush = new SolidColorBrush(Colors.Black);
public FontAwesomeIcon Icon
{
get { return _icon; }
set { _icon = value; }
}
public Brush IconBrush
{
get { return _brush; }
set { _brush = value; }
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return ImageAwesome.CreateImageSource(Icon, IconBrush);
}
`
On using the FontAwesome controls in XAML in multiple views, I am getting crashes. I looked at the code, and I believe the problem to be the use of a static FontFamily object which is getting shared across multiple dispatcher threads.
I tried replacing this shared FontFamily object with a ConcurrentDictionary with the dispatcher as key, and FontFamily as value, which means each dispatcher thread gets it's own FontFamily. This resolved my problem, and I'd be happy to commit the fix.
Hello fellow Font-Awesome fans:
I am using the WPF for my buttons in the following way:
<StackPanel Grid.Row="1" Grid.Column="2" VerticalAlignment="Center">
<Button Style="{StaticResource DefaultIcon}" fa:Awesome.Content="AngleDoubleRight" Command="{Binding SelectHeaderCommand}"></Button>
<Button Style="{StaticResource DefaultIcon}" fa:Awesome.Content="AngleDoubleLeft" Command="{Binding RevertSelectHeaderCommand}"></Button>
</StackPanel>
Now I would like to have the default hover change, since i have a transparent background already and only want the icon to change color, not the background:
I do not know what i need to fill in here, and how i could make the Content from the button filled in xaml pass through all the way to my template.
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MenuIcon}" x:Key="DefaultIcon">
<Setter Property="FontSize" Value="25"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
<!-- What should be filled in here? -->
<fa:FontAwesome Icon="{TemplateBinding fa:Awesome.Content}"></fa:FontAwesome>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red"></Setter>
<Setter Property="Foreground" Value="{StaticResource ForegroundBlueBrush}"></Setter>
</Trigger>
</Style.Triggers>
</Style>`
``
When I try to install the nuget package 4.3.0.2, I have this error:
Failed to add reference to 'PresentationCore'. Please make sure it is in the global assembly cache.
ImageAwesome
internally renders the glyph at 100x100 px, then scales it down to the target size (assuming it's less than 100px).
However this messes with the font weights. Consider this example (from here):
At small sizes, the typeface designer provides hints on how to map lines and details to pixels. At larger sizes, the icon feels heavier. When you scale it down, it ends up looking bold, fuzzy and without sharp detail.
Instead, ImageAwesome
should render at the required size, so no scaling occurs. The underlying Image.StretchDirection
should have its metadata overridden, setting the default to StretchDirection.None
.
Crisp icons at 96 DPI due to typeface hinting is one of the reasons to use fonts over the equivalent paths/geometry. By rendering the glyph at the wrong size, this benefit goes away.
Currently the page is loaded each time you start the nuget package manager console and this is driving me nuts.
I would like I have the capability to add more images to this library to be used as default. Is there an easy way to do this? Moreover, suppose I have a pro license of font awesome. then is it easy to attach this library to my license
Would it be possible to generate a function that receives string representing the ID of the icon, as can be found on https://fortawesome.github.io/Font-Awesome/icons/ , and returns the enum that can be bound in a fa:ImageAwesome tag?
If the string does not match with any valid icon, I'd imagine the function returning 'question', though maybe a second parameter could accept the preferred "error" icon, in the form of the enum.
TextBlock icons are sometimes placed outside of actual UIElement (apparent when clipping), probably something to do with LineHeight.
Is there any way, to set an FontAwesome Icon as the Icon of a Window?
For example, from http://fontawesome.io/icon/wpforms/:
The string used on the site is fa-wpforms
, but CssClassNameConverter
expects wpforms
.
I worked around this with code such as:
var faConverter = new CssClassNameConverter();
var converter = LambdaConverter.Create<string>(s =>
{
if (s.StartsWith("fa-"))
s = s.Substring(3);
return faConverter.Convert(s, typeof(FontAwesomeIcon), null, null);
});
But it would be better if the library did this.
It would be nice to change the Duration (default 1s) of ISpinable
control via a new DependencyProperty
.
Hi
I noticed that there are a bunch of nice new icons added in FontAwesome 4.6/4.7 and I would like to help to update this project to the most recent fontawesome version.
Are these the correct steps?
Regarding the NuGet version - did you align the version number to the FontAwesome version number or was there semver in mind?
I have a situation where I need a URI as an IconSource. How can I use FontAwesom.WPF in this situation?
Details:
"Extended WPF Toolkit" AvalonDock LayoutAnchorable has a property to set the panel icon ("IconSource") which requires a URI. The property does not allow binding. I want to use a FontAwesom icon as the panel icon.
<xcad:DockingManager>
<xcad:LayoutRoot x:Name="LayoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockMinWidth="200">
<xcad:LayoutAnchorable ContentId="Properties" Title="Properties" IconSource=" ??? ">
. . .
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutPanel>
</xcad:LayoutRoot>
</xcad:DockingManager>
I am trying to conditionally display icons using the below code.
<DataGridTemplateColumn Header="Level">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<fa:FontAwesome Icon="Warning"></fa:FontAwesome>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsError}" Value="True">
<Setter Property="Icon" Value="Stop" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
I am not even able to compile this due to the error
The member "Icon" is not recognized or is not accessible.
Can someone suggest a way to do this?
I want to use Pro in my UWP APP ... need help
I've faced with strange error I get on windows server 2012.
System.Windows.Markup.XamlParseException: Задание свойства "FontAwesome.WPF.ImageAwesome.Icon" вызвало исключение. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. в System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) в System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) в MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr) в MS.Internal.Text.TextInterface.Factory.GetFontCollection(Uri uri) в MS.Internal.FontCache.DWriteFactory.GetFontCollectionFromFileOrFolder(Uri fontCollectionUri, Boolean isFolder) в MS.Internal.FontCache.FamilyCollection.FromUri(Uri folderUri) в System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference, FontStyle& style, FontWeight& weight, FontStretch& stretch) в System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(FontStyle& style, FontWeight& weight, FontStretch& stretch) в System.Windows.Media.Typeface.ConstructCachedTypeface() в System.Windows.Media.Typeface.get_CachedTypeface() в System.Windows.Media.Typeface.CheckFastPathNominalGlyphs(CharacterBufferRange charBufferRange, Double emSize, Single pixelsPerDip, Double scalingFactor, Double widthMax, Boolean keepAWord, Boolean numberSubstitution, CultureInfo cultureInfo, TextFormattingMode textFormattingMode, Boolean isSideways, Boolean breakOnTabs, Int32& stringLengthFit) в MS.Internal.TextFormatting.SimpleRun.CreateSimpleTextRun(CharacterBufferRange charBufferRange, TextRun textRun, TextFormatterImp formatter, Int32 widthLeft, Boolean emergencyWrap, Boolean breakOnTabs, Double pixelsPerDip) в MS.Internal.TextFormatting.SimpleRun.Create(FormatSettings settings, CharacterBufferRange charString, TextRun textRun, Int32 cp, Int32 cpFirst, Int32 runLength, Int32 widthLeft, Int32 idealRunOffsetUnRounded, Double pixelsPerDip) в MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth, Double pixelsPerDip) в MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache) в MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak) в System.Windows.Media.FormattedText.LineEnumerator.FormatLine(TextSource textSource, Int32 textSourcePosition, Double maxLineLength, TextParagraphProperties paraProps, TextLineBreak lineBreak) в System.Windows.Media.FormattedText.LineEnumerator.MoveNext() в System.Windows.Media.FormattedText.DrawAndCalculateMetrics(DrawingContext dc, Point drawingOffset, Boolean getBlackBoxMetrics) в System.Windows.Media.FormattedText.Draw(DrawingContext dc, Point origin) в System.Windows.Media.DrawingContext.DrawText(FormattedText formattedText, Point origin) в FontAwesome.WPF.ImageAwesome.CreateImageSource(FontAwesomeIcon icon, Brush foregroundBrush, Double emSize) в FontAwesome.WPF.ImageAwesome.OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) в System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) в System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) в System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) в System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) в System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) в System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value) в MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value) в MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value) --- Конец трассировки внутреннего стека исключений --- в System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) в System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) в System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) в System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) в KX.CharterMaster.Diag2.zmKlOtQD67C43y0SSdO(Object , Object ) в KX.CharterMaster.Diag2.InitializeComponent() в F:\projects\mt\CharterMaster\CharterMaster.App\CharterMaster45\Diag2.xaml:строка 1 в KX.CharterMaster.Diag2..ctor() в KX.CharterMaster.Application.nHfG9eduq(Object , StartupEventArgs ) в F:\projects\mt\CharterMaster\CharterMaster.App\CharterMaster45\Application.xaml.vb:строка 241 в System.Windows.Application.OnStartup(StartupEventArgs e) в System.Windows.Application.<.ctor>b__1_0(Object unused) в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Here is the xaml
<Window x:Class="Diag2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:KX.CharterMaster" mc:Ignorable="d" Title="Diag2" Height="300" Width="300" xmlns:fa="http://schemas.fontawesome.io/icons/" > <Grid Margin="20"> <fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" /> </Grid> </Window>
If I comment
<fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" />
program starts nurmaly.
Hey, great work on this.
I have recently added this to my app and have removed quite a lot of images I designed myself in favor of this. I'm wanting to use this in collaboration with Material Menu, which can set an Image in the MenuButton Control ie:
<materialMenu:MenuButton Text="Settings" Image=""/>
I was wondering if there was a way in the xaml to have it use a fontAwesome image? Or would this have to be set in the code behind?
Many thanks.
replace font with vectors (svg) file.
Maybe provide control per glyph
<fa:Glas />
Hi! I know it is not a issue, but I dont know how to ask a question on git-hub...sorry..!
So I just wanted to know if and how we can add new icons to the set of icons found here?
thanks!
I think would be nice to have a stroke feature just like this
https://msdn.microsoft.com/en-us/library/ms745816.aspx
we can find an implementation here
http://stackoverflow.com/a/35262509/1345207
if someone will have the time to try this, i would suggest packetizing this as something new wich we could depend on.
The icons works fine when in runtime. But at design time they're not visible, making the design pretty annoying. I'm using VS2017 Community Edition.
Here's my Xaml
<fa:FontAwesome Icon="Backward" Foreground="Black" />
Strong name the assembly or it would not be usable in many situations
Good Day!
This looks incredible, but I'm concerned that it isn't updated to 5.x (won't worry about beta 6.X). I would like to use this going forward, but with additional icons being added, I wonder.
When using in other control (like ContentControl) ImageAwesome does not use the foreground provided by the parent.
Example:
<ContentControl Foreground="Red">
<TextBlock Text="FontAwesome" />
</ContentControl>`
This gives you a red TextBlock.
<ContentControl Foreground="Red">
<fa:ImageAwesome Icon="FontAwesome" />
</ContentControl>`
This gves you a black image, which should be red.
I'm using FontAwesome.WPF in version 4.7.0.9
I think this merge broke icon spinning functionallity.
If you set it to Collapse then set it to Visible again it's not spinning.
Even if the project is named and targets WPF - are you planning to support UWP projects as well?
When I try to install the package it fails:
FontAwesome.WPF 4.5.0.7 is not compatible with UAP,Version=v10.0.
Some packages are not compatible with UAP,Version=v10.0.
Maybe the code could "just work" on UWP and just the NuGet Package needs some updated targets.
Either create custom control or provide an example how to accomplish.
Add rotated and flipped in combination with spinning icons.
Reflection over sealed attributes is considerably faster.
https://msdn.microsoft.com/en-us/library/ms182267.aspx
IconCategoryAttribute, IconIdAttribute and IconAliasAttribute are all unsealed.
https://github.com/charri/Font-Awesome-WPF/blob/master/src/WPF/FontAwesome.WPF/Attributes.cs
I have added FontAwesome.WPF via Nuget (version 4.4.0.5). I'm getting the following errors when trying to use it inside my XAML:
The type 'fa:FontAwesome' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Unknown type 'FontAwesome' in XML namespace 'http://schemas.fontawesome.io/icons/'
When I try to ping schemas.fontawesome.io
it fails to resolve the name.
The name "FontAwesome" does not exist in the namespace "http://schemas.fontawesome.io/icons/"
i already added the xmlns:fa="http://schemas.fontawesome.io/icons/"
There's an example of setting an icon, but none of TextBlock purely in code-behind, how would I do that? so far in my attempts the binding error is FontAwesomeIcon
property not found on 'object'.
New Font Awesome 5.1 release, it would be lovely to use the new icons
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.