在按钮WP7中将源绑定到图像

时间:2012-05-10 17:13:05

标签: c# image windows-phone-7 bitmap

我实际上是想在我的按钮中将图像源绑定到我的图像,不知道什么是错的,但没有出现......

这是我的xaml

<Grid>
    <Grid x:Name="FakeGridBig" Background="White" Opacity="0.1" 
        HorizontalAlignment="Left" Width="714" Height="269" Margin="3,0,0,0"></Grid>
    <Button  x:Name="Featured_Big" MouseEnter="Featured_Big_MouseEnter_1"
        MouseLeave="Featured_Big_MouseLeave"
        ContentTemplate="{StaticResource FeaturedBig}" 
        Style="{StaticResource BlackOpacityButton}" 
        BorderThickness="0" VerticalAlignment="Top" Margin="0,0,11,0">
        <i:Interaction.Triggers>
            <i:EventTrigger EventName="Click" >
                <gs:EventToCommand Command="{Binding FeaturedBigImage.InnerCommand1}"/>
            </i:EventTrigger>
        </i:Interaction.Triggers>      
        <Image x:Name="bigimage" Height="269" Width="714" ></Image>
    </Button>                       
</Grid>

这就是背后的代码,uri实际上很好......

Uri uri = new Uri(FeaturedSmallImage1.Image1,UriKind.Absolute);
BitmapImage bmp = new BitmapImage(uri);
View.bigimage.Source = bmp;

1 个答案:

答案 0 :(得分:2)

我想说你的可能就在于这条线......

ContentTemplate="{StaticResource FeaturedBig}" 

根据模板的外观,它可以覆盖您尝试使用的图像。