2012-05-20 3 views
2

가로로 배열 된 항목이 하나, 왼쪽에 하나, 오른쪽으로 하나, 나머지는 인 마지막에 이있는 패널이 필요합니다. 나는 이것을 얻을 수 있습니다 :패널 크기 조정 동작

<DockPanel LastChildFill="True"> 
    <TextBlock DockPanel.Dock="Left" Text="TextLeft" FontSize="40" Foreground="DarkOrange"/> 
    <TextBlock DockPanel.Dock="Right" Text="TextRight" FontSize="40" Foreground="DarkOrange"/> 
    <TextBlock Text="TextMiddle" FontSize="40" HorizontalAlignment="Center"/> 
</DockPanel> 

enter image description here

그러나 폭이 같은 NOT "TextMiddle"로 먹게됩니다 "TextRight"입니다 항목 폭의 합보다 작은 경우 그 싶습니다 다음과 같습니다

enter image description here

주 필자 TextMiddle에의 minWidth를 추가하는 시도 -하지만이 는 동작 변화를하지 않습니다 - TextMiddle는 LastCh의 마지막 자식이기 때문이다 ildFill = "True"DockPanel.

<DockPanel LastChildFill="False" > 
    <TextBlock DockPanel.Dock="Left" Text="TextLeft" FontSize="40" Foreground="DarkOrange"/> 
    <TextBlock DockPanel.Dock="Left" Text="TextMiddle" FontSize="40" HorizontalAlignment="Center" /> 
    <TextBlock DockPanel.Dock="Right" Text="TextRight" FontSize="40" Foreground="DarkOrange"/> 
</DockPanel> 
:

XAML 아래 나에게 크기 조정올바른 behavor를 얻을 정도로 폭이있을 때 하지만 "TextMiddle"사용 가능한 공간에을 중심으로하지 않습니다 (TextRight 제한된 공간이 경우에 먹게됩니다) 어쩌면 항목 중 하나에 subpannel를 사용하여 - -

enter image description here enter image description here

나는이에 대한 쉬운 해결책이 확신하지만, 난 그냥 질수 정확히 어떻게 주위에 내 머리를 얻을. 어떤 도움을 많이 주셨습니다.

답변

1

아마도이게 무엇입니까? 확실히이

<Grid> 
    <Grid.RowDefinitions> 
    <RowDefinition /> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
    <ColumnDefinition Width="2*" MinWidth="350"/> 
    <ColumnDefinition Width="*"/> 
    </Grid.ColumnDefinitions> 
    <UniformGrid HorizontalAlignment="Stretch" Rows="1"> 
     <TextBlock Name="TextLeft" Text="TextLeft" FontSize="40" Foreground="DarkOrange"/> 
     <TextBlock Name="TextMiddle" Text="TextMiddle" FontSize="40" HorizontalAlignment="Center" /> 
    </UniformGrid> 
    <TextBlock Grid.Column="1" HorizontalAlignment="Right" Text="TextRight" FontSize="40" Foreground="DarkOrange"/> 
</Grid> 
+0

음하지 - 문제가 내 두 번째 XAML 블록으로 같은 동작을 제공합니다 (즉 올바른 행동의 크기를 조정하지만 MiddeText이 가능한 공간 중앙에 있지). 하지만 당신의 접근 방식이 좋다고 생각합니다. 어떻게 든 해결할 수 있어야합니다. – Ricibob

+0

지금은 어떨까요? – codekaizen

+1

지속은 돈을 지불합니다! MinWidth를 약간 만만치면 작동합니다. 고마워요 당신이 이것에 노력 - 내가 처음보다 훨씬 더 어려웠다 (나는 WPF allover thats 같아요). :-) – Ricibob

관련 문제