我現在發現了一個可行的解決方案。通過從該按鈕的背景,並加入以下內容:
<Button.Content>
<StackPanel Orientation="Vertical">
<Image Source="{Binding Path=Background}" Stretch="Fill" Height="100" Width="400" />
<TextBlock Margin="0,-130,0,0" Height="30" Width="400" HorizontalAlignment="Center"
TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Path=Title}"
Foreground="White" FontFamily="/Assets/futura-md.ttf#Futura Md BT"/>
</StackPanel>
</Button.Content>
具有背景定義如下:
public BitmapImage Background
{
get
{
return new BitmapImage(new Uri(string.Format("/Assets/knop_{0}.png",buttoncolor), UriKind.Relative));
}
}
public string ButtonImage
{
get { return buttonimage; }
set
{
buttonimage = value;
RaisePropertyChanged("ButtonImage");
RaisePropertyChanged("Background");
}
}
現在按鈕「背景」將被改變時的值ButtonImage已更改。
這不完全是我所希望的,但它的工作。
你能展示一些代碼嗎? – Romasz 2014-09-25 09:16:33