0
ボタンの背景を設定するのは、アンドロイドのdev.itより複雑です。 .xamlファイルにWP7コードでボタン画像をURLで変更する
:私はButton.Ifでこの画像を得ることができる方法
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"
は、ボタンの背景を設定する方法は何ができません。この中
<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>
は、ファイルを.CSコード内にURLがある。
ありがとう、このように私はImageSourceをURLで設定することができます。しかし、私にとって重要なことです。言い換えれば、どのようにImageコントロールをボタンで取得できますか? –
最後に私は[それ](http://stackoverflow.com/questions/9444091/how-to-reference-image-in-controltemplate "ありがとう男")、それはうまく動作します。 –