开发者

How to do that content of button show in the left in wp7?

开发者 https://www.devze.com 2023-04-12 04:18 出处:网络
I have a button with width of p开发者_运维知识库hone 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

I have a button with width of p开发者_运维知识库hone 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>


Simply set HorizontalContentAlignment="Stretch" on your button. The default is centre.

Then a grid with HorizontalAlignment="Stretch" will do what you want.


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号