在Silverlight中为弹出窗口添加图像到背景

时间:2012-08-15 22:10:37

标签: c# silverlight silverlight-4.0 popup background-image

问题 我想添加一个图像弹出的背景。我对Silverlight相当新,所以如果下面的代码中有一些明显的菜鸟错误我很抱歉

<Popup x:Name="MyPOP" HorizontalOffset="200" VerticalOffset="200" IsOpen="False"  >

        <StackPanel Width="800" Height="800" Background="Red">
            <Button Content="GO AMERICA" Click="Button_Click_1"  Width="100" Height="50" />
            <Canvas>
                <TextBlock Text="THESE COLORS DON'T RUN!!!!" />
            <Canvas.Background>
                <ImageBrush ImageSource="http://www.ilovethebronx.com/sites/default/files/events_pics/fireworks.jpg?1339518424"/>
            </Canvas.Background>

            </Canvas>
            </StackPanel>

    </Popup>    

有什么建议吗?提前致谢

1 个答案:

答案 0 :(得分:1)

你只需要在你的画布上设置一个高度,但我怀疑这更像是你可能会追求的:

<Popup x:Name="MyPOP" HorizontalOffset="200" VerticalOffset="200" IsOpen="True"  >

        <Grid Width="800" Height="800" Background="Red">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Button Content="GO AMERICA" Click="Button_Click_1"  Width="100" Height="50" />
            <Border Grid.Row="1">
                <TextBlock Text="THESE COLORS DON'T RUN!!!!" />
                <Border.Background>
                    <ImageBrush ImageSource="http://www.ilovethebronx.com/sites/default/files/events_pics/fireworks.jpg?1339518424"/>
                </Border.Background>

            </Border>
        </Grid>

    </Popup>