I have Button
on my WPF app and I want an Image
to fill the Button
completely. Currently I have The following code and it does not fill the Button
.
<Image x:Key="MyResource" Source="Images/up-arrow-icon.jpg" Margin="0" />
<telerik:RadButton Height="25" Width="40" HorizontalAlignment="Left" Margin="417,10,0,0"
Name="radButton1" VerticalAlignment="Top" Click="UpButtonClick">
<telerik:RadButton.Content>
<StaticResource ResourceKey="MyResource"/>
</telerik:RadButton.Content>
</telerik:RadButton>
Do I need resize the Image
outside WPF then use it?
Set
HorizontalContentAlignment
andVerticalContentAlignment
Properties of theButton
to beStretch
:See this question and this link for more
Try setting
HorizontalAlignment
andVerticalAlignment
toStretch
andDock
toFill
.The solution with the Button.Background worked for me only in the vertical direction (the button was shown as a 3 pixel wide vertical slice), because I needed to fit the refresh button on the right side into a horizontal
Grid
container as shown in this screenshot:So, I ended up binding the
Width
to theActualHeight
property and everthing's looking good to me:The resource I used is an ICO file so the image should be looking good in different sizes and imaging should still be very fast...
You can try changing your
Image
to anImageBrush
and then assign that to yourBackGround
your image will then stretch over the inner surface of your button.or add a TextBlock to your Button Content and assign your Image as a BackGround to it.