0

In preview all good, but when I compiling, there is no image. If problem in source, so why it is showing in preview window? preview

error

 <Grid>
    <!-- Grid 4x3 -->
    <Grid.RowDefinitions>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="0.5*"></RowDefinition>
        <RowDefinition Height="0.5*"></RowDefinition>
        <RowDefinition Height="0.7*"></RowDefinition>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.2*"></ColumnDefinition>
        <ColumnDefinition Width="1*"></ColumnDefinition>
        <ColumnDefinition Width="0.2*"></ColumnDefinition>
    </Grid.ColumnDefinitions>

    <!-- Controls -->
        <!-- Row №1-->
    <Image Grid.Row="0" Grid.Column="1" Source="pack://siteoforigin:,,,/Resources/logo.png"></Image>
        <!-- Row №2-3 -->
    <StackPanel Grid.Row="1" Grid.Column="1" Grid.RowSpan="2">
        <Label Content="Вы заходите как..."></Label>
        <ComboBox>
            <ComboBoxItem Content="Клиент"></ComboBoxItem>
            <ComboBoxItem Content="Сотрудник"></ComboBoxItem>
        </ComboBox>
        <Label Content="ID"></Label>
        <TextBox></TextBox>
        <Label Content="Пароль"></Label>
        <PasswordBox></PasswordBox>
    </StackPanel>
    <!-- Row №4 -->
</Grid>
Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36

2 Answers2

1

Seems that the image you specified is not copied to the output directory. You can resolve the issue in two ways:
1) In the property grid set Build Action to "None" and Copy to Output Directory to "Copy always" (you need to do this because the siteoforigin URI seeks the resource in the binary file location)
2) Set the Build Action property to "Resource" and use the pack://application absolute URI or the relative URI (like this: <Image Source="Resources/logo.png"/> )

Alexis
  • 815
  • 6
  • 15
0

Try to set source as this and see if it solve your problem.

<Image Source="/MonFitClub;component/Resources/logo.png"/>

where if i did see corectly MonFitClub is name od your Project.

ivica.moke
  • 1,054
  • 2
  • 10
  • 19
  • You don't need to specify the assembly name in a [Resource File Pack URI](https://msdn.microsoft.com/en-us/library/aa970069.aspx), when the URI references a resource in the local assembly. – Clemens May 15 '17 at 13:48
  • I know that, but i have a habit to always specify it :) i hope it's not a mistake to do that. – ivica.moke May 15 '17 at 13:59
  • No, but it's also not a good answer to the question, because you give no explanation at all. – Clemens May 15 '17 at 14:31