Windows phone 7 WP7使用url在代码中更改按钮图像

Windows phone 7 WP7使用url在代码中更改按钮图像,windows-phone-7,url,button,Windows Phone 7,Url,Button,设置一个按钮的背景并不像android的开发那样简单,它更复杂 在.xaml文件中: <Button Click="Button_Click" x:Name="img_btn"> <Button.Template> <ControlTemplate> <!--set button background that we can hanle click event--

设置一个按钮的背景并不像android的开发那样简单,它更复杂

在.xaml文件中:

       <Button Click="Button_Click" x:Name="img_btn">
            <Button.Template>
                <ControlTemplate>
           <!--set button background that we can hanle click event-->
                    <Image  HorizontalAlignment="Left" Margin="0,-69,0,479" x:Name="image1" Stretch="Fill" Width="480" Source="/myNameSpace;component/home_003.jpg" />
                </ControlTemplate>
            </Button.Template>
        </Button>
如何在按钮中获取此图像。如果不能,如何使用代码中的url设置按钮背景

试试这个

首先创建图像源,然后将该源提供给正在使用的图像控件

字符串imagepath=“url”

ImageSource imgsrc1=新位图图像(新Uri(imagepath,UriKind.RelativeOrAbsolute)); //图像可以是图像/图像笔刷
image.Source=imgsrc1

谢谢,通过这种方式我可以设置一个带有url的ImageSource。但是对我来说很重要。总之,我怎样才能在一个按钮中获得一个图像控件;我终于找到了,而且效果很好。
                JsonObject jsonObject = (JsonObject)JsonObject.Load(e.Result);
                ads_address = jsonObject["imageurl"];//get a url from jsonobject
                ImageBrush imageBrush = new ImageBrush();
                imageBrush.ImageSource = new BitmapImage(new Uri(ads_address));//ads url likes //"http://27.98.194.93/forum/images/2009/home_004.jpg";

                this.img_btn.Background = imageBrush;//this code is not work,perhaps, I can't get what I want(Image) with code "this.img_btn.Background"