vb.net - image is not displayed when running WPF

0

Good morning, I have the following design:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:WpfApplication2"
    mc:Ignorable="d"
    Title="MainWindow" Height="350" Width="525">

<Grid Margin="0,0,0,0" Background="CadetBlue">
    <Border BorderBrush="DimGray " BorderThickness="2,2,2,2" Background="AliceBlue" Padding="5" CornerRadius="28" Margin="52,0,155,219" Height="52" VerticalAlignment="Bottom">
        <DockPanel HorizontalAlignment="Left" Height="46" LastChildFill="True" Margin="-2,-1,0,-7" VerticalAlignment="Top" Width="275">
            <Image x:Name="image" Height="46" VerticalAlignment="Top" Width="41" Source="pack://siteoforigin:,,,/Resources/user (1).png" />
            <TextBox BorderBrush="Transparent" x:Name="textBox" TextWrapping="Wrap" Text="TextBox" DockPanel.Dock="Right" Width="234" Height="40" VerticalAlignment="Top"/>
        </DockPanel>
    </Border>
</Grid>

But I have a problem when executing, because it ignores the image and only shows this:

I add that when I added the image I did it as a resource. What is the problem? How can I solve it?

    
asked by Raphael 03.01.2017 в 20:56
source

2 answers

0

Almost certainly there is no file "pack: // siteoforigin: , / Resources / user (1) .png". When you use siteoforigin instead of application, you have to copy the file to the path you indicate (with respect to the executable).

Check that the file exists, that it is really called user (1) .png (with space in between), and test with application instead of siteoforigin, since you say you have added it as a resource.

I think this information will suit you:

answered by 04.01.2017 в 17:28
0

Try putting only this address:

 Source="Resources/user(1).png"

It has happened to me that when I gave him F5, the images did not load. However with Ctrl + F5 everything runs OK

    
answered by 04.01.2017 в 21:28