2014-09-24 91 views
0

我想在2D UI中創建一個按鈕(在這種情況下,它是一旦我開始我的應用程序時打開的選擇窗口),它具有木製面板作爲背景。此圖像應平鋪,並且不能拉伸以適合整個按鈕。WPF紋理按鈕

此外,我希望當光標移到按鈕上時,背景圖像不會消失。

我該如何做到這一點?

+0

請發佈你到目前爲止嘗試過的內容。 – honk 2014-09-24 12:22:43

+0

[如何設置背景圖片](http://stackoverflow.com/questions/3100837/how-to-set-background-image-on-grid-in-wpf-using-c-sharp) – 2014-09-24 12:23:18

回答

2

的XAML代碼應該是這樣的:

<Button> 
<Button.Content> 
<Grid height="40" width="40"> <!--you can adjust the height and wdith according to your preferences--> 
<Image Source="your_path_to_image" /> 
</Grid> 
<Button.Content> 
</Button> 

,當你按下按鈕的圖像不應該dissapear,但即便如此,使用cicked事件和懸停和威脅他們。如果你沒有成功通過這篇文章發表評論,我將爲你編寫和發佈一個工作示例:)