Special K.
Special K.

Reputation: 520

Panorama Image Title (bind image path)

I was wondering if it's possible to bind the image path when using an Image as the Panorama Title, the reason why I need a bind for the Source is that when the user have the phone background to "white" the logo would be black, and vice versa.

This is the code I'm using:

<controls:Panorama.TitleTemplate>  
<DataTemplate>
    <Image Source="/PanoramaApp5;component/Images/logo.png"  Margin="14,105,0,10" HorizontalAlignment="Left" Name="logo" Stretch="Fill" VerticalAlignment="Top" Width="700" Height="70"/>
    <!--<TextBlock Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="100" Margin="10,50,0,0" />-->
    </DataTemplate> 
</controls:Panorama.TitleTemplate>

If I let the default Title (which is text), it will work just fine, but I need it as an image.

Upvotes: 1

Views: 879

Answers (2)

Graham Smith
Graham Smith

Reputation: 2275

Just to provide an example of a working version, Facebook uses this same method in the header of their Windows Phone application and instead of user binding they automatically pull photos of the user to stick together and use in the pano

Upvotes: 1

Kevin Gosse
Kevin Gosse

Reputation: 39007

Just set an empty binding for your image source, then assign it using the Title property of your panorama:

<controls:Panorama x:Name="Panorama">
    <controls:Panorama.TitleTemplate>
        <DataTemplate>
            <Image Source="{Binding}" />
        </DataTemplate>
    </controls:Panorama.TitleTemplate>
</controls:Panorama>

Then from the code behind:

this.Panorama.Title = new Uri("uri of your picture");

Upvotes: 2

Related Questions