2017-11-24 18 views
0

다른 스택 패널이있는 스택 패널이 있고 두 번째 패널이 첫 번째 스택 패널의 중앙에 있도록하고 싶습니다. 이러한 패널의 방향이 변경되었습니다. 수직 정렬 아무것도 작동하지 않습니다 ..부모 항목 높이의 중앙에 자식 항목을 수직으로 정렬하는 방법

아무도 이것에 일해? 당신의 도움을 받고 싶습니다.

업데이트 :

<StackPanel Grid.Row="0" Grid.RowSpan="4" Background="White" Visibility="Visible" Orientation="Vertical"> 

       <StackPanel VerticalAlignment="Center" Grid.Row="0"> 
        <ProgressBar Margin="0,15,0,0" 
        IsIndeterminate="True" 
        IsEnabled="True" Foreground="Black"/> 
        <TextBlock Visibility="Visible" Margin="6,6,6,15" Foreground="Black" FontSize="21" TextWrapping="WrapWholeWords" HorizontalAlignment="Center" Text="Loading..."/> 
       </StackPanel> 
     </StackPanel> 
+0

쇼 당신이 뭘하려 :

있습니다 (기본 상태입니다 나는 또한 Visible 이후 Visibility 값을 제거) 항목을 중앙에 Grid 또는 Border를 사용해야합니까? –

+0

나는 veritcal과 child 스택에 mother stack의 방향을 중심으로 설정하려고 시도했다. – Shiva

+0

코드를 보여 주면 우리가 알아낼 것이다. –

답변

2

여기서 문제는 StackPanel입니다. 스택 패널이하는 일은 한쪽 (상단, 왼쪽 ...)의 항목을 쌓아서 StackPanel에 항목의 중심을 완전히 맞출 수 없다는 것입니다. 항목이 세로로 쌓인 경우 VerticalAlignment 속성은 패널의 직접 하위 항목에 영향을 미치지 않습니다. HorizontalAlignment 및 수평 적 스태킹에도 동일하게 적용됩니다.

<Grid Grid.Row="0" 
     Grid.RowSpan="4" 
     Background="White" 
     > 
    <StackPanel HorizontalAlignment="Center" 
       VerticalAlignment="Center" 
       Grid.Row="0" 
       > 
     <ProgressBar Margin="0,15,0,0" 
        IsIndeterminate="True" 
        IsEnabled="True" 
        Foreground="Black" 
        /> 
     <TextBlock Margin="6,6,6,15" 
        Foreground="Black" 
        FontSize="21" 
        TextWrapping="WrapWholeWords" 
        HorizontalAlignment="Center" 
        Text="Loading..." 
        /> 
    </StackPanel> 
</Grid> 
0

당신은 부모 StackPanel에 수평으로 방향을 설정해야합니다 ...이보십시오.

<StackPanel Grid.Row="0" Grid.RowSpan="4" Background="White" Visibility="Visible" Orientation="Horizontal"> 

       <StackPanel VerticalAlignment="Center" Grid.Row="0"> 
        <ProgressBar Margin="0,15,0,0" 
        IsIndeterminate="True" 
        IsEnabled="True" Foreground="Black"/> 
        <TextBlock Visibility="Visible" Margin="6,6,6,15" Foreground="Black" FontSize="21" TextWrapping="WrapWholeWords" HorizontalAlignment="Center" Text="Loading..."/> 
       </StackPanel> 
     </StackPanel>