Click here to Skip to main content
15,442,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dll/assembly that I am creating as a library. I have a ResourceDictionary which I am able to use correctly. I also have an Images sub-directory that holds .png files I'm using for icons.

Everything builds fine I have XAML like

XML
<Style x:Key="ApplyButton" BasedOn="{StaticResource imgButton}" TargetType="Button">
        <Setter Property="ToolTip" Value="Apply"/>
        <Setter Property="IsDefault" Value="True"/>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <Image Source="/Images/Apply.png" Stretch="Uniform" ></Image>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="UpButton" BasedOn="{StaticResource imgButton}" TargetType="Button">
        <Setter Property="ToolTip" Value="Move Up"/>
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <Image Source="pack://application:,,,/Images/Arrow-Up.png" Stretch="Uniform" ></Image>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>


Both image sources compile fine, but if I don't have a matching Image directory in the calling program with images with the same name, I don't get an image. I would like the ResourceDictionary to use the images in the local assembly and not need one in the calling assembly.

I've tried both compiling the images with 'Content' and 'Resource'. I suspect I am incorrectly setting the Source on the Image in the ResourceDictionary.
Posted
Comments
[no name] 27-Aug-13 14:05pm    
See if this http://wangmo.wordpress.com/2007/09/30/compile-meida-files-into-a-separate-assembly/ helps you.
bowlturner 27-Aug-13 14:15pm     CRLF
It's on the right track. I'm doing basically that for the ResourceDictionary. The problem is the resourcedictionary when compiling is pointing correctly at the right image directory, but when it is being referenced in the calling application it is looking for the Image in a place relative to the calling app, not the dll where it resides. I could use the link but I would have to create another project just to hold my resources so the Resoucedictionary dll could reference it as a separate assembly. While this could work, it is less than ideal since it adds another dll I need to track.
[no name] 27-Aug-13 14:55pm    
I do not see why you could not employ the same technic on a DLL that is already in your project. The principal is the same.
bowlturner 27-Aug-13 15:03pm     CRLF
The problem is that both files (the ResourceDictionary and the .png I'm trying to reference) are in the same project/assembly/dll and using a dll reference doesn't appear to work, since at the time of compiling, the dll I'm trying to reference doesn't yet exist. So as I pointed out, I'd have to split my current project into 2 separate projects (2 dlls) to make it work that way and I'd rather not if I can help it. If I am missing something your trying to tell me please try again. I would love a solution where the XAML and the images reside in the same project.
bowlturner 28-Aug-13 10:02am    
I decided to go with this approach and it does work just fine. Thanks for the help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900