0

我在 Silverlight 中有一个图像按钮,在初始加载时它会显示demo1图像,每当我单击该按钮时,我都应该将图像更改为demo2.

<Button x:Name="demo"
        IsEnabled="False"
        Click="demo_Click"
        ToolTipService.ToolTip="demo"
        Width="25"
        Height="25"
        VerticalAlignment="Bottom"
        HorizontalAlignment="Left" 
        Margin="0,0,0,25">

    <Image x:Name="demo-image" Source="/demo.content;component/demo1.png"/>

</Button>
4

2 回答 2

1

首先,IsEnabled="False"ButtonXAML 中删除。然后只需demo_Click在您的代码隐藏中实现事件处理程序,如下所示:

private void demo_Click(object sender, RoutedEventArgs e)
{
    demo_image.Source = new BitmapImage(
        new Uri("/demo.content;component/demo2.png", UriKind.Relative));
}
于 2012-08-02T09:44:14.560 回答
0

您可以改用ToggleButton

于 2012-08-03T18:12:54.523 回答