我正在使用MahApps Metro,这是我的Button
:
<Button
Name="startBtn"
Width="55"
Height="55"
VerticalAlignment="Top"
Style="{DynamicResource MetroCircleButtonStyle}"
Click="playBtn_Click">
<Rectangle
Width="25"
Height="25">
<Rectangle.Fill>
<ImageBrush
ImageSource="pack://application:,,,/Resources/start.ico" />
</Rectangle.Fill>
</Rectangle>
</Button>
所以我想改变Button
内的image
Button Click Event
:
private void startBtn_Click(object sender, RoutedEventArgs e)
{
}
答案 0 :(得分:0)
XAML:
<Button
Name="startBtn"
Width="55"
Height="55"
VerticalAlignment="Top"
Style="{DynamicResource MetroCircleButtonStyle}"
Click="playBtn_Click">
<Image Width="25" Height="25" Source="pack://application:,,,/Resources/start.ico" />
</Button>
代码:
private void startBtn_Click(object sender, RoutedEventArgs e)
{
((sender as Button).Content as Image).Source = new BitmapImage(new Uri("yourpath.png"));
}