Twarei
Twarei

Reputation: 84

C# Windows phone page background isn't set

I want to set a page background to an image that i download from web, and it works only in designer view. But when i start the app in emulator or on device it just doesn't work(it doesn't get downloaded and set). Mainfest is set to require internet connection. I've tried to find the solution but with no success...

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Background>
        <ImageBrush Stretch="UniformToFill">
            <ImageBrush.ImageSource>
                <BitmapImage UriSource="http://i.imgur.com/XAAcx5d.jpg"/>
            </ImageBrush.ImageSource>
        </ImageBrush>
    </Page.Background>
</Page>

Upvotes: 4

Views: 77

Answers (2)

Kcs Windows
Kcs Windows

Reputation: 1

modify your code like this.

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Page.Background>           
     <ImageBrush ImageSource="http://i.imgur.com/XAAcx5d.jpg" Stretch="UniformToFill"/>              
    </Page.Background>
</Page>

Upvotes: 0

Didgeridoo
Didgeridoo

Reputation: 1262

Seems your image has hotlink protection.

You can try to load image manually: 1 or 2. Or you can try to add control <Image ...> to XAML and then subscribe to event ImageFailed of Image class and see what's happened.

Upvotes: 3

Related Questions