我有這樣的XAML代碼:更改圖片來源時,母按鈕改變它的啓用狀態
<Button x:Name="ButtonUpdate" IsEnabled="False">
<Image Source="Images/update gray.png" Name="ImgUpdate" >
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Source" Value="Images/update.png" />
</Trigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Button>
我想,當ButtonUpdate
啓用:
ButtonUpdate.IsEnabled = true;
的ImgUpdate.Source
成爲"Images/update.png"
,當ButtonUpdate
未啓用:
ButtonUpdate.IsEnabled = false;
ImgUpdate.Source
使用數據綁定變成"Images/update gray.png"
。
我的XAML代碼不起作用。錯誤在哪裏?我該如何解決它?
但啓動時圖像「Images/update gray.png」顯示正確... – Nick 2013-04-29 17:36:41