c# - 如何在 WPF 中设置 SVG 图像的颜色?
问题描述
我们从模型中接收到 SVG 图像路径。这个镜像也用在 web 和 winform 上,所以我们不能使用 XAML。这些只是灰色图像,我们需要能够为这些图像设置任何颜色。我想知道是否可以添加某种仅设置非透明部分颜色的颜色层?
这是我现在所拥有的:
<Window x:Class="CustomBrushesExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:svg1="clr-namespace:SVGImage.SVG;assembly=DotNetProjects.SVGImage"
xmlns:local="clr-namespace:CustomBrushesExample" WindowStartupLocation="CenterScreen"
Title="SVGImage" Height="540" Width="720" Background="Wheat" ResizeMode="NoResize" Margin="3">
<svg1:SVGImage
x:Name="StartingImage" SizeType="SizeToContent"
Source="/CustomBrushesExample;component/Images/test_3.svg"
Margin="20"
RenderTransformOrigin="0.5,0.5"
VerticalContentAlignment="Top"
HorizontalContentAlignment="Left"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
</Window>
SVGImage 是显示 SVG 图像的 .net 团队实现:https ://github.com/dotnetprojects/SVGImage
解决方案
推荐阅读
- javascript - 无法使用日期条件对数组进行排序
- azure-data-factory - 解析 CSV 文件中的 json 列值
- java - Firebase 评论的用户名不正确
- gitlab-ci - Gitlab CI/CD 运行单元测试
- angular6 - Angular 6中的Pdf滑块轮播
- javascript - 调用时在javascript中返回类对象属性的内容
- sql - SELECT 的行为变化
- django - 当同一个数据库中有两个同名的模型和不同的应用程序时,django中的using()应该使用哪个模型?
- python - 如何在 QTableWidget 中仅获取包含值的行/列数?
- reactjs - react hook form - watch vs onchange,哪个是正确的方法