Skip to content

Instantly share code, notes, and snippets.

@lostmsu
Created September 14, 2020 23:46
Show Gist options
  • Save lostmsu/6b7a5f226406483641cb6fe5a2cdd1a6 to your computer and use it in GitHub Desktop.
Save lostmsu/6b7a5f226406483641cb6fe5a2cdd1a6 to your computer and use it in GitHub Desktop.
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:zones="clr-namespace:LostTech.Stack.Zones;assembly=Stack"
mc:Ignorable="d"
Width="1024" Height="576"
d:DesignWidth="1024"
d:DesignHeight="576"
zones:Layout.Version="2"
>
<!-- for a tutorial on how to lay the zones out,
see https://www.codeproject.com/Articles/140613/WPF-Tutorial-Layout-Panels-Containers-Layout-Trans
or any other WPF layout tutorial -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<zones:Zone x:Name="Left" Grid.RowSpan="2">
<zones:Zone.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked, ElementName=StackLeft}" Value="True">
<Setter Property="zones:Zone.Layout">
<Setter.Value>
<ItemsPanelTemplate>
<UniformGrid Columns="1" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</zones:Zone.Style>
</zones:Zone>
<zones:Zone x:Name="Right" Grid.RowSpan="2" Grid.Column="1" />
<zones:Zone x:Name="TopLeft"/>
<zones:Zone x:Name="BottomLeft" Grid.Row="1"/>
<zones:Zone x:Name="TopRight" Grid.Column="1"/>
<zones:Zone x:Name="BottomRight" Grid.Column="1" Grid.Row="1"/>
<!-- Since Left is defined before TopLeft and BottomLeft inside the same Grid,
it would normally appear below them, so you would not be able to drop windows to Left:
mouse would always hit TopLeft or BottomLeft first.
Here we define drop zones for Left and Right, that would float above Top* and Bottom*,
which would direct the window to Left or Right.
Note 'Margin'. It tells how much area leave around the drop zone.
'Target' tells where to drop to,
-->
<zones:Zone x:Name="LeftDropZone" Target="{Binding ElementName=Left}"
Margin="40" Grid.RowSpan="2"
/>
<zones:Zone x:Name="RightDropZone" Target="{Binding ElementName=Right}"
Margin="40" Grid.RowSpan="2" Grid.Column="1"
/>
<CheckBox x:Name="StackLeft" Grid.Column="0" Grid.Row="2"
/>
</Grid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment