Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to use Button Style

Button.Content= img+Text?
Posted
Updated 7-Jan-11 7:38am

Set content to a DockPanel or StackPanel containig image + text

XML
<Button>
  <DockPanel>
     <Image Source="image.png"/>
     <Text DockPanel.Dock="fill" VerticalAlignment="center"> Button
         <Italic>with Image!</Italic>
     </Text>
  </DockPanel>
</Button>


Regards
Espen Harlinn
 
Share this answer
 
Use a StackPanel to place an Icon at the top and text at the bottom.


C#
<Button>
	<stackpanel>
		Orientation="Vertical">
		<Image
			Height="32"
			Margin="4,4,4,4"
			Source="Icons/MyButton.ico" />
		<textblock>
			Text="MyText"
			Margin="4,4,4,4"
			VerticalAlignment="Center" />
	</textblock></stackpanel>
</Button>



(the formatting gets changed by the website but you get the idea)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900