-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to convert a PackIconMarkup to a Geometry object? #256
Comments
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:
Happy coding |
I had write a custom 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} /> |
@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 Anyway thank you for the idea. 👍 |
Actually I'm using the attach property reference: |
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 |
C# Code or XAML is fine.
The text was updated successfully, but these errors were encountered: