The easiest way to adapt the transformation. For example:
<Window x:Class="..." xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="Animation test" Height="350" Width="525"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Border Background="DeepSkyBlue"> <Border.Style> <Style TargetType="Border"> <Style.Triggers> <DataTrigger Binding="{Binding ShowAdditionalUI}"> <DataTrigger.Value> <sys:Boolean>True</sys:Boolean> </DataTrigger.Value> <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation To="0" Duration="0:0:1" Storyboard.TargetProperty=" (UIElement.RenderTransform). (TranslateTransform.X)"/> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> <DataTrigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Duration="0:0:1" Storyboard.TargetProperty=" (UIElement.RenderTransform). (TranslateTransform.X)"/> </Storyboard> </BeginStoryboard> </DataTrigger.ExitActions> </DataTrigger> </Style.Triggers> </Style> </Border.Style> <Border.RenderTransform> <TranslateTransform X="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType=UIElement}}"/> </Border.RenderTransform> <TextBlock>Дополнительный выезжающий контент</TextBlock> </Border> <CheckBox IsChecked="{Binding ShowAdditionalUI}" Grid.Row="1"> Показать выезжающий контрол </CheckBox> </Grid> </Window>
(Note that the reverse animation does not indicate To , so the offset will roll back to the “normal” value.)
The "invisible" part of the control should be limited to the container of this control, and thus not visible. If you can still see it, put Border in an intermediate container with ClipToBounds="True" :
<Border ClipToBounds="True"> <!-- вот это добавляем --> <Border Background="DeepSkyBlue"> ... </Border> </Border>
Result (screenshot in the process of animation):
