I have the following directory structure
Project \Images +view.png control.xaml
and in the control, I have a button defined by the following XAML:
<Button Click="Search" Grid.Column="1" Margin="0,5,5, 0" HorizontalAlignment="Right"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> <Image Source="pack://application:,,,/images/view.png" Width="16" Height="16" ToolTip="Search" Cursor="Hand" Opacity="0.8" /> </ControlTemplate> </Button.Template> </Button>
However, neither this package URI method nor "/images/view.png" work. As far as I understand, this is the same problem, this question is being raised. However, I get the same error. The confusing thing is that in Visual Studio 2008 the image is displayed correctly, but when I call the InitializeComponent () call, I get:
It is not possible to convert the string 'pack: // application: ,, / images / view.png' to the attribute 'Source' for an object of type 'System.Windows.Media.ImageSource'. Cannot find the resource 'images / view.png'. Error in the object "System.Windows.Controls.ControlTemplate" in the markup file "RecapSpecEditControl; component /modaltreadgroupdatadialog.xaml" Line 61 Position 40.
I thought that there might have been a namespace that I should have declared, but according to msdn site , I believe I don't need to do anything.
source share