ElinamLLC / SharpVectors

SharpVectors - SVG# Reloaded: SVG DOM and Rendering in C# for the .Net.
https://elinamllc.github.io/SharpVectors/
BSD 3-Clause "New" or "Revised" License
718 stars 136 forks source link

`AppName` case style may determine whether show svg image or not #263

Open Hellager opened 1 year ago

Hellager commented 1 year ago

I'm a front end developer and new to c#, prefer to use snake case in code. So when i create a project which has a snake case namesapce, the svg image will not show unless it's camel case.

<!-- In Camel Case, Everything goes fine -->
<Window x:Class="WpfSvgTestBox.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:svgc="http://sharpvectors.codeplex.com/svgc/"
        xmlns:local="clr-namespace:WpfSvgTestBox"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button Visibility="Visible" Background="Transparent" ToolTip="Clean" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,7,10">
            <Button.Resources>
                <Style TargetType="Border">
                    <Setter Property="CornerRadius" Value="16"/>
                </Style>
            </Button.Resources>

            <StackPanel>
                <Image Source="{svgc:SvgImage Source=Assets/Icons/MySvgIcon.svg, AppName=WpfSvgTestBox}" Width="32" Height="32" />
            </StackPanel>
        </Button>
    </Grid>
</Window>

<!-- In Snake Case, the svg image will not show -->
<Window x:Class="wpf_svg_testbox.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:svgc="http://sharpvectors.codeplex.com/svgc/"
        xmlns:local="clr-namespace:wpf_svg_testbox"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Button x:Name="ManualCleanButtonLight" Visibility="Visible" Background="Transparent" ToolTip="Clean" BorderThickness="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,7,10">
            <Button.Resources>
                <Style TargetType="Border">
                    <Setter Property="CornerRadius" Value="16"/>
                </Style>
            </Button.Resources>

            <StackPanel>
                <Image Source="{svgc:SvgImage Source=Assets/Icons/MySvgIcon.svg, AppName=wpf_svg_testbox}" Width="32" Height="32" />
            </StackPanel>
        </Button>
    </Grid>
</Window>

Is this designed to be working like it ? Or we should be able to use snake case?

paulushub commented 1 year ago

@Hellager The property AppName is the base name of the DLL or EXE containing the SVG file. WPF designer does not provide a interfaces at design-time, so AppName helps to identify the DLL/EXE containing the SVG. I do not know if there is a special behavior of DLL/EXE name in snake case - will have to look into it.