Unable to use [xml]$template = @" in visual studio

I’m trying to add in some toast notifications, in ISE this works fine, but in visual studio, it never closes the element correctly and thinks the rest of my code is quoted text and throws an error.
# Define the toast notification in XML format

[xml]$ToastTemplate = @"
    <toast duration="long">
        <visual>
        <binding template="ToastGeneric">
            <image placement="hero" src="$HeroImage"/>
            <image placement="appLogoOverride" hint-crop="circle" src="$ImageFile"/> 
            <text>$Sender</text>    
            <group>
                <subgroup>
                    <text hint-style="body" hint-wrap="true" >$Message</text>
                </subgroup>
            </group>
        </binding>
        </visual>
        <audio src="$AudioSource"/>
    </toast>
        "@


Tries using single quotes too, but the issue still persists.

Fixed it… no white space allowed before the closing "@
So much for clean indentation!

in ISE this works fine

Thanks for sharing the solution. It seems like this behavior is present in ISE too as it is part of the design of PowerShell.