Reputation: 61
I used translatetransform to slide my child window but I think there's something wrong with my xaml code. It's not the window is sliding but inside the window is sliding (or the grid).
This is my Child Window XAML:
<Window x:Class="SAMPLE.ChildWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterOwner"
x:Name="HomeWindows"
Title="HomeWindow" Height="348" Width="440" Loaded="HomeWindows_Loaded">
<Window.RenderTransform>
<TranslateTransform />
</Window.RenderTransform>
<Window.Resources>
<Storyboard x:Key="SlaydAndFeyd" >
<DoubleAnimation Storyboard.TargetName="HomeWindows" Storyboard.TargetProperty="(Window.RenderTransform).(TranslateTransform.X)" From="50" To="0" Duration="0:0:0.4" />
</Storyboard>
</Window.Resources>
and then for my function, calling the storyboard:
public void SlaydAndFeyds()
{
(FindResource("SlaydAndFeyd") as Storyboard).Begin(this);
}
and now in the Main Window code:
namespace SAMPLE
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private ChildWindow NewChildWindow = new ChildWindow();
private void btnShowChild_Click(object sender, RoutedEventArgs e)
{
NewHomeWindow.Owner = this;
NewHomeWindow.Show();
}
private void btnSlideChild_Click(object sender, RoutedEventArgs e)
{
NewHomeWindow.SlaydAndFeyds();
}
or anyone have an idea how can I slide my child window?
Upvotes: 0
Views: 834
Reputation: 34908
The RenderTransform in that example will affect the contents of the window, not the window itself.
To move the window, adjust the Left/Top attributes using an EventTrigger. I'm taking a guess that you want to slide it left by 50 pix or so over 4 seconds, adjust the figures to suit:
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation BeginTime="00:00:00"
Storyboard.TargetName="HomeWindows"
Storyboard.TargetProperty="(Window.Left)"
By="-12"
Duration="0:0:4" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
Upvotes: 1