blendには、FluidLayoutと呼ばれる機能があります。
ブレンド中
- 、新しい状態グループを作成し、遷移時間を設定し、流体レイアウトを可能にします。
- 水平方向に1つ、垂直方向に2つの状態を作成します。
- 次に、動作を使用して動作を切り替えることができます。
あなたはブレンドを持っていない場合は、必要なファイルのMicrosoft.Expression.InteractionsとSystem.Windows.Interactivityを持っている必要がありSDKをダウンロードすることができます。これらへの参照を追加し、以下のサンプルを試してみてください。
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:il="clr-namespace:Microsoft.Expression.Interactivity.Layout;assembly=Microsoft.Expression.Interactions"
xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
x:Class="WpfApplication4.MainWindow"
x:Name="Window"
Title="MainWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<VisualStateManager.CustomVisualStateManager>
<ic:ExtendedVisualStateManager/>
</VisualStateManager.CustomVisualStateManager>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Orientation" ic:ExtendedVisualStateManager.UseFluidLayout="True">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.3000000"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Vertical"/>
<VisualState x:Name="Horizontal">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="stack" Storyboard.TargetProperty="(StackPanel.Orientation)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Orientation.Horizontal}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<StackPanel x:Name="stack" Margin="8,49,8,8">
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
<Button Content="Button"/>
</StackPanel>
<Button HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="97" Height="25" Content="H">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ic:GoToStateAction StateName="Horizontal"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button HorizontalAlignment="Left" Margin="109,8,0,0" VerticalAlignment="Top" Width="97" Height="25" Content="V">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ic:GoToStateAction StateName="Vertical"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Window>
あなたはGrid.Row、ROWSPAN、コルを変更することにより、要素またはを移動する状態を使用してアイテムの移行を処理するために同様の方法を使用することができます。すべてを結びつけるためにいくつかのコードが必要な場合があります。問題を整理すると、私はより精巧なサンプルを見ています。
私の場合、翻訳変換を行うためのコードを書く必要があると言われています。誰かが素敵な方法で出てくるかどうかは面白いでしょう。 – Ray
ViewBoxと関係のある特定の領域に配置しようとしていますか?たとえば、ViewBoxのサイズに関係なく、常にViewBoxの左下に配置できますか? –
これは、*望ましい効果*を達成できないかもしれませんが、この変更をアニメーション化するよりスムーズな方法は実装するのがより複雑かもしれませんが、StackPanelの方向を変更するときにテキストを消して戻すことができます( 'DataTrigger '、そしてそのStart-/EndActionsのようなものですが、タイミングの権利をどれくらい簡単に手に入れることができないのかはわかりません...) –