2012-04-24 7 views
3

グリッドが4つあります。最初の列には、ZIndexが99で内部がエキスパンダーのキャンバスがあります。展開方向は右に設定されます。ヘッダーをクリックすると、エキスパンダーが列2の上に展開されます...これはまさに私が望むものです。私はこれを(逆方向のみ)列4内に複製しようとしているので、展開すると3列目に表示されます。2番目のエクスパンダのExpandDirectionを "Left"にマークしたにもかかわらず、右、画面外です。ここでキャンバス内にWPFエキスパンダーが展開されない

は作業エキスパンダーである:ここでは

<Canvas Grid.Column="0" Panel.ZIndex="99" Grid.RowSpan="4" VerticalAlignment="Stretch" Margin="0,5"> 
    <Expander ExpandDirection="Right" Style="{DynamicResource OptionsExpanderStyle}" VerticalAlignment="Stretch" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}"> 
     <Border BorderBrush="Black" BorderThickness="0,0,2,0"> 
      <Grid Background="White"> 

      </Grid> 
     </Border> 
    </Expander> 
</Canvas> 

は壊れエキスパンダーです:

<Canvas x:Name="rightCanvas" Panel.ZIndex="99" Grid.RowSpan="4" Grid.Column="3" Margin="0,5"> 
    <Expander ExpandDirection="Left" Style="{DynamicResource OptionsExpanderStyle}" HorizontalAlignment="Right" VerticalAlignment="Stretch" Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Canvas}}}"> 
     <Border BorderBrush="Black" BorderThickness="2,0,0,0"> 
      <Grid Background="White" Width="150"> 

      </Grid> 
     </Border> 
    </Expander> 
</Canvas> 
+0

なぜキャンバスを使用して:

はそのような何かを試してみてください? –

+0

@ NicolasRepiquet、それは私が列2と3にあるコントロールの残りの部分を拡張することを可能にする私が見つけた唯一の方法でした。これを行うための他の方法?単純にZIndexをエキスパンダーの上に置くだけでは機能しません。 – Thelonias

答えて

3

キャンバスを使用しないでください。

<Grid> 
    <Grid> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition/> 
      <ColumnDefinition/> 
     </Grid.ColumnDefinitions> 
     <TextBlock Background="LightBlue" 
      TextAlignment="Center" Text="Left Column"/> 
     <TextBlock Grid.Column="1" Background="LightCoral" 
      TextAlignment="Center" Text="Right Column"/> 
    </Grid> 
    <Expander Background="LightGray" ExpandDirection="Right" 
     Header="LeftMenu" VerticalAlignment="Top" HorizontalAlignment="Left"> 
     <StackPanel Width="200"> 
      <TextBlock Text="Some menu stuff"/> 
      <TextBlock Text="Some more"/> 
     </StackPanel> 
    </Expander> 
    <Expander Background="LightGray" ExpandDirection="Left" 
     Header="RightMenu" VerticalAlignment="Top" HorizontalAlignment="Right"> 
     <StackPanel Width="200" > 
      <TextBlock Text="Some menu stuff"/> 
      <TextBlock Text="Some more"/> 
     </StackPanel> 
    </Expander> 
</Grid> 
+0

私は同意します。エキスパンダーは正しく展開されますが、キャンバス内を移動します。 –

+1

あなたは本当にすべてのキャンバスを取り除くべきです:D –

+1

キャンバスを使うべきではない理由を説明する人がいますか?私は上記の答えを実装する過程にありますが、なぜ人々が私がキャンバスを使用すべきではないと言っているのか不思議です。 – Thelonias

関連する問題