在 WPF 中使用矢量图像的最佳方法? [英] Best way to use a vector image in WPF?

查看:24
本文介绍了在 WPF 中使用矢量图像的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在 XAML 中处理矢量文件(EPS 或 SVG)的好方法.我找到了一个插件,可以将图像从 Illustrator 导出到 XAML,如果我将文件的内容复制到我的窗口,它就可以很好地工作.

I am looking for a good method to handle a vector files (EPS or SVG) in a XAML. I found a plugin that exports an image from Illustrator to a XAML , and it works well if I copy the content of the file to my window.

但是,是否可以将 xaml 输出用作资源或其他东西,并从给定的 XAML 窗口示例中导入/转换它?

But, is it possible to use the xaml output instead as a resource or something, and import/convert it from the given XAML window example?

我正在使用的工具:Adobe Illustrator to Xaml.

推荐答案

就个人而言,如果您要在多个地方使用它而不必每次都重新使用/重新绘制您的 xaml 路径.然后我只是将它们放入 ContentControl 中,例如;

Personally, if you're talking about using it in multiple places without having to re-use / re-draw your xaml paths each time. Then I just plop them in a ContentControl like;

<!-- Plop this in your resource dictionary or your resource declaration -->
    <Style x:Key="TheAwesomeXAMLimage" TargetType="ContentControl">
            <!-- Add additional Setters Here -->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ContentControl">

                                <!-- Just Paste your XAML here -->

                </ControlTemplate>
            </Setter.Value>
        </Setter>                      
    </Style>

<!-- Now actually place it on your view -->
    <ContentControl Style="{StaticResource TheAwesomeXAMLimage}"/>

这篇关于在 WPF 中使用矢量图像的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆