tags:

views:

496

answers:

2

In my XAML and when I build I get the following exception:

Error 3 Value 'colorpick.png' cannot be assigned to property 'Source'. Value does not fall within the expected range.

Here is the XAML:

The "Source="colorpick.png" is underlined.

One of the few things I could find regarding this was the below blog post: http://nickeandersson.blogs.com/blog/2008/06/wpf-image-and-v.html

colorpick.png is set to Build action = resource.

Any hints would be greatly appreciated!

Here's all the xaml:

<UserControl x:Class="MyApp.Controls.ColorSettings"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyApp">
    <Grid>
        <StackPanel>
          <ScrollViewer>
           <ListView Name="lvColors" MinHeight="100" MinWidth="300" SelectionChanged="lvColors_SelectionChanged">
                <ListView.ItemContainerStyleSelector>
                    <local:ColorSettingsStyleSelector/>
                </ListView.ItemContainerStyleSelector>
                <ListView.View>
                <GridView>
                    <GridViewColumn Header="Level" DisplayMemberBinding="{Binding Level}"></GridViewColumn>

                    </GridView>
            </ListView.View>
        </ListView>
        </ScrollViewer>
            <StackPanel Orientation="Horizontal" Name="spColorPicker" Visibility="Hidden">
                <Image Source="colorpick.png" Width="200" Height="200" MouseLeftButtonDown="Image_MouseLeftButtonDown" MouseMove="wheel_MouseMove" Name="wheel"/>
                <Rectangle Width="200" Height="200" Name="rectDisplay"/>
            </StackPanel>
        </StackPanel>

    </Grid>
</UserControl>
+2  A: 

I think you might need to use the WPF Resource File Pack URIs syntax.

Erich Mirabal
Worked great. Thank you.
Adam Driscoll
+2  A: 

Try changing it to

<Image Source="/AssemblyName;component/colorpick.png" ...

where AssemblyName is the name of your assembly (component is a literal).

That's assuming colorpick.png is in root of your project, if it's in (for example) an images folder use /AssemblyName;component/images/colorpick.png

Ray
This did not work but thank you for trying.
Adam Driscoll
I had a couple of typos with colons instead of semi-colons. Maybe that was it.
Ray