我使用 translatetransform 来滑动我的子窗口,但我认为我的 xaml 代码有问题。不是窗口在滑动,而是窗口内部在滑动(或网格)。
这是我的子窗口 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>
然后对于我的功能,调用情节提要:
public void SlaydAndFeyds()
{
(FindResource("SlaydAndFeyd") as Storyboard).Begin(this);
}
现在在主窗口代码中:
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();
}
或者有人知道如何滑动我的子窗口?