Van*_*nel 0 custom-controls custom-attributes windows-phone-7
我正在开发一个Windows Phone应用程序.
我有一个自定义按钮,里面有一个图像.这是它的XAML代码:
<ControlTemplate x:Key="ImageButton" TargetType="Button">
<Grid>
<Image Margin="45,8,35,8" Source="Images/Delete.png"/>
</Grid>
</ControlTemplate>
Run Code Online (Sandbox Code Playgroud)
如何以编程方式更改图像源属性?
要更改图像的来源,您需要创建资产的新位图并将其设置为源
BitmapImage myBitmapImage = new BitmapImage(new Uri("/Images/foo.png", UriKind.Relative));
imageButton.Source = myBitmapImage;
Run Code Online (Sandbox Code Playgroud)
但我想你想要一个按钮,如果点击它就会改变它的背景.您需要重新定义按钮的可视状态.这是一个例子:
Windows Phone 7(WP7)单击更改按钮的背景颜色
| 归档时间: |
|
| 查看次数: |
2947 次 |
| 最近记录: |