2011-03-31 4 views
5

내가 StackPanel에있는 두 개의 버튼을 추가하고 코드Windows Phone 7에서 스택 패널의 버튼을 정렬하는 방법은 무엇입니까?

<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
<Button Content="Button" Height="64" Name="button1" Width="160" HorizontalAlignment="Left" VerticalAlignment="Top"/> 
<Button Content="Button" Height="64" Name="button2" Width="160" HorizontalAlignment="Right" VerticalAlignment="Top"/> 
</StackPanel> 

에 표시하지만 내 요구 사항과 일치하지 않는 정렬을 설정했습니다. 아래 그림과 같이 나타나기를 바랍니다.

enter image description here

그래서 내가 어떻게 할 수 있습니까? 이 같은

+5

은 Windows Phone 7입니까? 아이폰처럼 보입니다 :-) – Shoban

+0

아이폰 만 있습니다. 그게 요구 사항이야 – rubyraj

+0

마크와 코드가 4 칸만큼 들여 쓰기 때문에 질문에 올바르게 표시 될 수 있습니다. 질문을 편집 할 때 오른쪽에 표시되는 Markdown 문서를 읽는 것을 고려하십시오. – AnthonyWJones

답변

6

뭔가 :

<Grid 
    Width="480"> 

    <Grid.ColumnDefinitions> 
     <ColumnDefinition 
      Width="*" /> 
     <ColumnDefinition 
      Width="*" /> 
    </Grid.ColumnDefinitions> 

    <Button 
     Width="200" 
     Content="Clear" /> 

    <Button 
     Grid.Column="1" 
     Width="200" 
     Content="Options" 
     HorizontalAlignment="Right" 
     /> 

</Grid> 

UPDATE : 인기 수요, 여기에 고정 폭 또는 열이없는 그리드 인해.

<Grid> 

    <Button 
     Width="150" 
     Content="Clear" 
     HorizontalAlignment="Left" 
     /> 

    <Button 
     Width="150" 
     Content="Options" 
     HorizontalAlignment="Right" 
     /> 

</Grid> 
+0

두 개의 열이 정말로 필요합니까? – AnthonyWJones

+0

이것으로 나는 원하는 것을 얻는다. 그러나 나의 gui는 방해 받는다 이것을하는 어떤 다른 길도 거기에있다. 그리드를 사용하지 않고도이 작업을 수행 할 수 있습니까? – rubyraj

+0

@rubyraj : "방해받는"무엇을 의미합니까 ?? '그리드 (Grid)'는 당신이 우리에게 말하지 않은 다른 요구 사항이 없다면 직업에 적합한 도구일까요? – AnthonyWJones

관련 문제