0

My problem that I cannot use the image background in my resource but if I use the Directory from the different folder the background work fine. So what should I do?

Here is my code and the error message from visual studio.

<Window x:Class="Jan1_Launcher.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:Jan1_Launcher"
        mc:Ignorable="d"
        Title="Jan1" Height="350" Width="525">
    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="#FF4F1212" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>
    <Grid x:Name="Name">
        <Grid.Background>
            <ImageBrush ImageSource="a.png"/>
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Label x:Name="Game_Name" Content="Jan 1 Survival Game" HorizontalAlignment="Left" Height="24" Margin="21,10,0,0" VerticalAlignment="Top" Width="125"/>
        <Label x:Name="label" Content="Patch 0.0.1" HorizontalAlignment="Left" Height="24" Margin="134,16,0,0" VerticalAlignment="Top" Width="69"/>
        <Button x:Name="UpdateBut" Content="Download Update" HorizontalAlignment="Left" Height="34" Margin="58,247,0,0" VerticalAlignment="Top" Width="145" IsDefault="True" Click="UpdateBut_Click"/>
        <Button x:Name="PlayBut" Content="Play" HorizontalAlignment="Left" Height="34" Margin="322,247,0,0" VerticalAlignment="Top" Width="145" Click="PlayBut_Click" Background="#FF111111" BorderBrush="Black" OpacityMask="Black" Foreground="White" FontSize="14" FontFamily="Arial"/>
    </Grid>
</Window>

Error Message:

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '17' and line position '14'.

Tim Hoang
  • 13
  • 3
  • What resource? There are no resources at all in the code you show. Have you actually declared an image resource somewhere? Are you familiar with the [pack URI scheme](https://msdn.microsoft.com/en-us/library/aa970069(v=vs.110).aspx)? Without being able to actually reproduce your exception, i.e. with a good [mcve], it's not likely anyone will be able to tell you specifically what you need to fix. – Peter Duniho Jul 02 '16 at 05:00
  • Here is the photos – Tim Hoang Jul 02 '16 at 07:52
  • Here is the photo in Visual Studio. http://imgur.com/K5mkSgc – Tim Hoang Jul 02 '16 at 07:53
  • See here: http://stackoverflow.com/a/18375601/1136211 – Clemens Jul 02 '16 at 11:59

0 Answers0