Comments (5)
Hi @GF-Huang
I have a PR open which provides an export button to the browser. It is not merged yet but feel free to clone my branch and build the browser on your own. See:
- #232 for the PR
- https://github.com/timunie/MahApps.Metro.IconPacks/tree/HamburgerMenuProposal for the branch to build
- https://github.com/MahApps/MahApps.Metro.IconPacks/wiki/How-to-build-the-solution for how to build the solution.
Happy coding
Tim
from mahapps.metro.iconpacks.
I had write a custom MarkupExtension
to do this, I hope this will be add into this repo.
public abstract class PackIconGeometryExtension<TKind> : MarkupExtension where TKind : Enum {
public TKind Kind { get; set; }
protected abstract IDictionary<TKind, string> DataIndex { get; }
protected PackIconGeometryExtension() { }
protected PackIconGeometryExtension(TKind kind) => Kind = kind;
public override object ProvideValue(IServiceProvider serviceProvider) => Geometry.Parse(DataIndex[Kind]);
}
public class UniconsGeometryExtension : PackIconGeometryExtension<PackIconUniconsKind> {
protected override IDictionary<PackIconUniconsKind, string> DataIndex => PackIconUniconsDataFactory.DataIndex.Value;
public UniconsGeometryExtension() { }
public UniconsGeometryExtension(PackIconUniconsKind kind) : base(kind) { }
}
// and so on..
public class XxxGeometryExtension : PackIconGeometryExtension<PackIconXxxKind> {
protected override IDictionary<PackIconXxxKind, string> DataIndex => PackIconXxxDataFactory.DataIndex.Value;
public XxxGeometryExtension() { }
public XxxGeometryExtension(PackIconXxxKind kind) : base(kind) { }
}
Usage:
<MyButton Geometry={iconPacks:UniconsGeometry Kind=Xxx} />
from mahapps.metro.iconpacks.
@GF-Huang tbh at the moment I don't see a good usecase for this. Not all Icons are build the same way, so you would need to take care of this. Some geometries are mirrored, others are outline only, others are filled, etc. So just rutrning the path data may lead to wrong appearance.
Moreover I don't see the the benefit right now. Maybe you can share a sample App via github repro where we can have a look at your extension and the MyButton
- Control? Maybe then your point gets clearer or we have an alternative idea for your usecase.
Anyway thank you for the idea. 👍
from mahapps.metro.iconpacks.
Actually I'm using the attach property Iconelement.Geometry
from HandyControl
, but just to make my suggestion a little bit simpler, I'll just say MyButton
. Maybe I replace the `<Path x:Name="PathMain" ... /> to something PackIcon will be better?
reference:
- HandyControl
- <Style x:Key="ButtonBaseStyle" BasedOn="{StaticResource ButtonBaseBaseStyle}" TargetType="Button">...</Style>
- IconElement.cs
from mahapps.metro.iconpacks.
Hi @GF-Huang
<StackPanel>
<TextBlock>IconContent-Example</TextBlock>
<Button Style="{DynamicResource Handy.Styles.Buttons.IconProposal}" Content="Proposal" hc:IconElement.IconContent=":-)"
Background="Red">
<hc:IconElement.IconTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="15" FontFamily="Courier New" FontWeight="Bold" />
</DataTemplate>
</hc:IconElement.IconTemplate>
</Button>
<Button Style="{DynamicResource Handy.Styles.Buttons.IconProposal}" Content="IconPacks Example"
hc:IconElement.IconPosition="Right"
hc:IconElement.IconContent="{iconPacks:Material Kind=Teach}"
Background="BlueViolet" />
</StackPanel>
I know this will lead to some work on your side, but I think this is way more flexible. You can then have any object as Icon, even Images or other controls. Moreover the Icon can change based on buttons content. Your Geometry can also still be used the same way.
I've sent you a draft PR which needs to be reworked on your own. HandyOrg/HandyControl#767
Happy coding
Tim
from mahapps.metro.iconpacks.
Related Issues (20)
- bug: bound icons in an ItemsControl are shown incorrectly. Error appeared on 4.4.0 (it did work correctly on 4.3.0) HOT 2
- "MahApps.Metro.IconPacks.Core" Nuget-Package
- Drop .NET Framework 4.5.2 and 4.6 which will reach End of Support on April 26, 2022
- Question: how to convert an icon to System.Drawing.Icon? HOT 1
- Include the Microsoft Windows11 explorer icons
- iconPacks:PackIconSimpleIcons HOT 1
- UWP Crashes at Startup when built in Release mode when using some Icon Packs HOT 10
- Could not load file or assembly 'MahApps.Metro.IconPacks.FontAwesome, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0c0d510f9915137a' or one of its dependencies. The system cannot find the file specified. HOT 2
- VS2022 WPF Designer Crashes Most Times with Icons HOT 3
- Material Design Icons v7.0.96
- Publish icon file generators for use in PRs HOT 2
- Drop the UWP support because it's a mess with the new Sdk project files
- Unable to resolve type Material HOT 4
- VS2022 can't find IconPacks resource HOT 9
- Flipped icon paths? HOT 1
- Update RemixIcon to V3.5 HOT 2
- IconPack spin not working HOT 1
- Is there any plan to update the Nuget version recently?
- IconPacks for MAUI
- Merge all dlls into one HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mahapps.metro.iconpacks.