0

I've downloaded the Visual Studio 2015 Image Library, and want to use icons from that in my WPF window. I am a big proponent of vector images, and each of the icons are given in .ai and .xaml formats; I imagine the latter would be a lot easier to include. Indeed, if I copy the contents of the file where I want them (as an image label for a button), it works perfectly. That doesn't seem like good encapsulation, though -- especially if I wind up reusing the images elsewhere -- so I'd rather leave the code in the files and include those. Unfortunately, everything I've been able to find is based on wrapping the vector definition in resource tags (e.g. <Window.Resources> from this answer or <ResourceDictionary> from this one) while I'd, hopefully understandably, rather leave the file untouched after importing them into my project; the root element in the file is a <Viewbox> and so is not anywhere in the "Create Data Binding" dialog:

<!-- This file was generated by the AiToXaml tool.-->
<!-- Tool Version: 14.0.22307.0 -->
<Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <Rectangle Width="16" Height="16">
        <Rectangle.Fill>
            <DrawingBrush>
                <DrawingBrush.Drawing>
                    <DrawingGroup>
                        <DrawingGroup.Children>
                            <GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" />
                            <GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M14.752,7.9492L6,2.1352 6,3.0002 3,3.0002 3,13.0002 6,13.0002 6,13.8872z" />
                            <GeometryDrawing Brush="#FF414141" Geometry="F1M7,4L12.958,7.958 7,12z" />
                            <GeometryDrawing Brush="#FF414141" Geometry="F1M4,12L5.001,12 5.001,4 4,4z" />
                        </DrawingGroup.Children>
                    </DrawingGroup>
                </DrawingBrush.Drawing>
            </DrawingBrush>
        </Rectangle.Fill>
    </Rectangle>
</Viewbox>

That leaves me needing to find some tag that allows me to embed an XAML file in its entirety, whether I then put that in some ResourceDictionary or directly in the button. Looking through the list and what options the Properties dialog gives me, it seems like I need to add a Source="/img/NextFrameArrow.xaml" to something, but <Image> complains about not supporting the file format (same for <ImageDrawing> and ImageSource=...) and everything else I've tried either doesn't have the Source parameter to begin with or doesn't display the image correctly.

Am I just overlooking the perfect tag? Is there some quick (and, crucially, specifiable from XAML) method of converting an XAML vector to something <Image> recognizes? Or do I just have to bite the bullet and add the <ResourceDictionary> tags to the image files?

Community
  • 1
  • 1
WovenTales
  • 45
  • 1
  • 6
  • @Clemens Mind pointing me to which question this is a duplicate *of*? I know there's a lot about how to use the XAML vector tags as images by making them a StaticResource, but that's not what I asked -- I want to know if it's possible to link to or reference an element defined elsewhere *without* wrapping the *definition* in a ResourceDictionary. If that was already answered somewhere, great, but I can't find it. – WovenTales Jan 14 '17 at 20:26
  • There is a link to the duplicate at the top of your question. – Clemens Jan 14 '17 at 20:42
  • Ah, sorry! Missed that somehow. Thanks, though! – WovenTales Jan 14 '17 at 21:21

0 Answers0