受啓發this question我會使這個問題複雜化。在WPF中點擊更改圈子「啓動 - 停止」按鈕背景圖片
我的目標是一個圓按鈕(與像背景圖像)whick執行像「啓動 - 停止」按鈕:
1)第一次點擊改變按鈕圖象「停止」圖像並啓動一些計算功能(進程,任務等)
2)enother click button button image to the original「start」image and stopping the function。
按鈕的代碼是這樣的:
<Button x:Name="btnStartStop" Width="72" Height="72" Content="" Margin="180,0,372,94" VerticalAlignment="Bottom" d:LayoutOverrides="VerticalAlignment">
<Button.Template>
<ControlTemplate>
<Grid>
<Ellipse>
<Ellipse.Fill>
<ImageBrush ImageSource="Images/Start.jpg"/>
</Ellipse.Fill>
</Ellipse>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
謝謝。
P.S. @Sheridan要求提及他的名字,也許他可以幫助我。
UPDATE我的按鈕看起來非常像我的背景圖像 - 它是無邊框和可點擊區域相匹配的圖像(它是圓的)。該圓形圖像之外的所有內容都是透明的,並且不會觸發點擊事件這就是爲什麼我必須使用Ellipse。
從您的[**第一鏈接**]以編程方式設置它(無DataTriggers)的方法(http://stackoverflow.com/questions/5971300/programmatically-changing-button-icon-in-wpf/5973592#5973592 )最適合我。但是我不能使用'btnStartStop.Content = FindResource(「Stop」)',因爲你可以看到我需要在Button裏面的Ellipse裏設置ImageBrush的圖像源。我怎樣才能做到這一點? – bairog
請檢查更新我的答案,讓我知道任何幫助.. –
Thx尋求幫助,但你不明白我的按鈕看起來像(可點擊區域應該是EXACT的圖片 - 一個圓圈)。我已更新我的原始帖子。 – bairog