Reputation: 3268
I have a button with width of phone width,I want that button content be image in the left corner and text after image, I put image and text into stackpanel, grid and canvas and gives HorizantalAllignment="Left" but always the content shown in the center, how I can do what I want or which other control I can use,please help me
<Border BorderThickness="0,0,0,2" BorderBrush="#FF479175">
<Button Height="90" BorderThickness="0">
<Grid>
<Image Source="/HomePageDes;component/Images/main_news.png" Height="80" HorizontalAlignment="Left" />
<TextBlock Text="News" />
</Grid>
</Button>
</Border>
Upvotes: 2
Views: 1152
Reputation: 93551
Simply set HorizontalContentAlignment="Stretch" on your button
. The default is centre
.
Then a grid with HorizontalAlignment="Stretch"
will do what you want.
Upvotes: 3
Reputation: 7103
I think that is what you are asking:
<Button>
<StackPanel Orientation="Horizontal">
<Image src=""/>
<TextBlock Text="ClickMe"/>
</StackPaenl>
</Botton>
If you are using Grid as your container, then you need to define Grid Columns and place the image in column 0 , and the text in column 1. Easier to use Stackpanel in this case.
For example:
<Button>
<Grid HorizontalAlignment="Left">
<Grid. ColumnDefinitions >
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid. ColumnDefinitions>
<Image Source="/HomePageDes;component/Images/main_news.png" Height="80" HorizontalAlignment="Left" Grid.Column="0"/>
<TextBlock Text="News" Grid.Column="1"/>
</Grid>
</Button>
Upvotes: 2