wpf controls - WPF customized image button -


I have created an image button in WPF with a PGN file. However, there is always a limit outside the button image, is there any way to get rid of it? I tried to set the image 'Stretch =' filling ', the border of the button is up to 0 but nobody is working till now.

Thanks for all the answers here is my code. I tried to set things up with a style What is the difference between my code and your code? I'm a bit confused with the content template and the control template you specify.

  style x: key = "TopPositionButtonStyle" TargetType = "button" & gt; & Lt; Setter property = "width" value = "50" /> & Lt; Setter property = "height" value = "30" /> & Lt; Setter property = "padding" value = "0" /> & Lt; Setter Property = "Borderbrush" value = "Steelblue" /> & Lt; Setter Property = "BorderTitches" value = "0" /> & Lt; Setter Property = "Content Template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Grid background = "steelblue" & gt; & Lt; Image source = "picture / button_up.png" horizontal alignment = "center" margin = "0,0,0,0" height = "30" width = "50" extension = "fill" /> & Lt; TextBlock Text = "POSITION" horizontal align = "center" foreground = "white" margin = "5,5,0,0" /> & lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;    

the default is more than the default padding . The first thing to try this should be:

  padding = "0"   

If he does not tell you what you want in the next step To remove the template in a few ways:

  & lt; Button content = "{StaticResource HowEverImageIsSet}" & gt; & Lt; Button.Template & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Border background = "{templatebiding background}" borderline = "0" padding = "0" & ​​gt; & Lt; ContentPresenter / & gt; & Lt; / Border & gt; & Lt; / ControlTemplate & gt; & Lt; /Button.Template> & Lt; / Button & gt;    

Comments