Binding Image source issue
Posted: 08 Feb 2019, 05:55
I can't seem to bind my image element's source. What I have is the following:
The interesting part being:
The Image is a member of a class and is a path to the .png image I want to display.
The error I get is:
Code: Select all
<ListBox Grid.Row="1"
ItemsSource="{Binding Turrets, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemTemplate>
<DataTemplate>
<Button Command="{Binding DataContext.ButtonClickCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
CommandParameter="{Binding}">
<Button.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Name="TurretImage"
Grid.Row="0"
Grid.RowSpan="6"
Grid.Column="0"
Width="50"
Height="50"
Source="{Binding Image}"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Radius}" />
<TextBlock Grid.Column="1" Grid.Row="1" Text="{Binding Damage}" />
<TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding Name}" />
<TextBlock Grid.Column="1" Grid.Row="3" Text="{Binding FireDelay}" />
<TextBlock Grid.Column="1" Grid.Row="4" Text="{Binding Kills}" />
<TextBlock Grid.Column="1" Grid.Row="5" Text="{Binding Cost}" />
</Grid>
</Button.Content>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>Code: Select all
<Image Name="TurretImage"
Grid.Row="0"
Grid.RowSpan="6"
Grid.Column="0"
Width="50"
Height="50"
Source="{Binding Image}"/>The error I get is:
NoesisException: Unable to load image 'Assets/Sprites/turret.png'.
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.Extend.Noesis_InstantiateExtend_ (System.IntPtr nativeType) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtendImports.cs:26)
Noesis.Extend.NewCPtr (System.Type type, System.Object instance) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtend.cs:3896)
Noesis.Extend.GetInstanceHandle (System.Object instance) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtend.cs:4288)
Noesis.Extend.ListGet (System.IntPtr cPtr, System.UInt32 index) (at Assets/NoesisGUI/Plugins/API/Core/NoesisExtend.cs:2036)
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.View.Noesis_View_SetSize_ (System.Runtime.InteropServices.HandleRef view, System.Int32 width, System.Int32 height) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:409)
Noesis.View.SetSize (System.Int32 width, System.Int32 height) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:44)
NoesisView.UpdateSettings () (at Assets/NoesisGUI/Plugins/NoesisView.cs:660)
NoesisView.LateUpdate () (at Assets/NoesisGUI/Plugins/NoesisView.cs:673)