Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 设置WindowsFormsHost动画_C#_Wpf_Animation_Windowsformshost - Fatal编程技术网

C# 设置WindowsFormsHost动画

C# 设置WindowsFormsHost动画,c#,wpf,animation,windowsformshost,C#,Wpf,Animation,Windowsformshost,我需要设置WindowsFormsHost控件的动画。问题是我看不到动画,窗口不刷新。如果在动画期间调整WPF窗口的大小,则过渡可见 我尝试将WindowsFormsHost放置在网格中,然后设置网格动画,但结果是一样的。我在网格中加入了一些其他内容,以确保我正确地编写了动画 下面是一些简单的应用程序来测试这一点: <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/win

我需要设置WindowsFormsHost控件的动画。问题是我看不到动画,窗口不刷新。如果在动画期间调整WPF窗口的大小,则过渡可见

我尝试将WindowsFormsHost放置在网格中,然后设置网格动画,但结果是一样的。我在网格中加入了一些其他内容,以确保我正确地编写了动画

下面是一些简单的应用程序来测试这一点:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    Title="MainWindow" Height="350" Width="525">

<Window.Resources>
    <Grid x:Key="MoveX">
        <Grid.RenderTransform>
            <TranslateTransform X="0"/>
        </Grid.RenderTransform>
    </Grid>

    <Storyboard x:Key="Story">
        <DoubleAnimation 
            Storyboard.Target="{StaticResource MoveX}"
            Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)"
            From="0"
            To="600"/>
    </Storyboard>
</Window.Resources>

<Grid>
    <Grid.RenderTransform>
        <TranslateTransform X="{Binding Source={StaticResource MoveX}, Path=RenderTransform.(TranslateTransform.X)}"/>
    </Grid.RenderTransform>

    <WindowsFormsHost Height="224" HorizontalAlignment="Left" Margin="26,24,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="404" Background="#FF762323">
        <wf:Panel BackColor="Green" Width="300" Height="200"/>
    </WindowsFormsHost>

    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="328,269,0,0" Name="button1" VerticalAlignment="Top" Width="75" >
        <Button.Triggers>
            <EventTrigger RoutedEvent="Button.Click">
                <BeginStoryboard Storyboard="{StaticResource Story}"/>
            </EventTrigger>
        </Button.Triggers>
    </Button>
    <Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="85,269,0,0" Name="label1" VerticalAlignment="Top" />
</Grid>
</Window>


有没有办法解决这个问题?

在混合使用WPF和WinForms或ActiveX内容时,这是一个众所周知的问题。在内部,每个渲染引擎都有自己的空域,不可能正确地实现类似动画的互操作性

随着.NET4.5的发布,这个问题应该得到解决


请参阅

混合WPF和WinForms或ActiveX内容时,这是一个已知问题。在内部,每个渲染引擎都有自己的空域,不可能正确地实现类似动画的互操作性

随着.NET4.5的发布,这个问题应该得到解决


请看

这太糟糕了。有人能证实吗?太糟糕了。有人能证实吗?