Base16.Svg.BuildTasks
1.0.0
dotnet add package Base16.Svg.BuildTasks --version 1.0.0
NuGet\Install-Package Base16.Svg.BuildTasks -Version 1.0.0
<PackageReference Include="Base16.Svg.BuildTasks" Version="1.0.0" />
paket add Base16.Svg.BuildTasks --version 1.0.0
#r "nuget: Base16.Svg.BuildTasks, 1.0.0"
// Install Base16.Svg.BuildTasks as a Cake Addin #addin nuget:?package=Base16.Svg.BuildTasks&version=1.0.0 // Install Base16.Svg.BuildTasks as a Cake Tool #tool nuget:?package=Base16.Svg.BuildTasks&version=1.0.0
Base16.Svg.BuildTasks
This package adds a custom build task that generates DrawingVisuals from SVG-files (Scalable Vector Graphics) which can then be directly used and referenced in WPF (Windows Presentation Foundation) applications.
This simplifies the process of creating a scalable UI using SVGs.
By adding a reference to this package all SVG-files in the referencing project will get a DrawingVisual
generated with the same name as the SVG-file and a namespace that corresponds to the files location in the project structure.
Since this approach uses code-generation no additional runtime dependencies are required.
Getting Started
- Create a new WPF application and call it
WpfSvgTestApp
using either .NET Core or .NET Framework - Add a reference to this NuGet-package
- Create a new folder in your project called
Svg
- Add any SVG-file that you might have to the
Svg
folder (see known issues) and name the fileMySvg.svg
- Verify that
Build Action
for the SVG-file is set toSvg Visual
/SvgVisual
- Open
MainWindow.xaml
and replace the content with the following
<Window x:Class="WpfSvgTestApp.MainWindow"
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:WpfSvgTestApp"
xmlns:Svg="clr-namespace:WpfSvgTestApp.Svg"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.Background>
<VisualBrush Stretch="Uniform">
<VisualBrush.Visual>
<Svg:MySvg />
</VisualBrush.Visual>
</VisualBrush>
</Grid.Background>
</Grid>
</Window>
- Compile and run the application
Known issues
- If
Svg Visual
/SvgVisual
is not available asBuild Action
after first adding this package simple unload and reload the project/solution - Symbols are currently not handled - only the "root visual" will get processed - this might change
- "CSS type styles" are not handled
- "Advanced masks" are not handled
- Filenames are not mangled/normalized/cleaned - the name of the file will be used as the name of the generated
DrawingVisual
(excluding extension) - ...
Change log
Version 1.0.0
Initial release.
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.7.1
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 632 | 2/2/2020 |