1

我在 Blend 4 中创建了一个带有徽标的动画,我希望它像用户控件一样在我的 WinfForms 中我如何将 WPF 与 WinForms(vb.net) 合并,这样它就像一个用户控件,当我曾经想要它吗?


到目前为止,我尝试将其添加为新项目,但它不起作用!

非常感谢链接

这是 wpf 的 xaml

    <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="MainWindow"
x:Name="Window"
Title="MainWindow"
Width="300" Height="150">
<Window.Resources>
    <Storyboard x:Key="OnLoaded1"/>
    <Storyboard x:Key="OnLoaded2">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
            <EasingDoubleKeyFrame KeyTime="0" Value="-42"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="38"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="118"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="198"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse">
            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy">
            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-42"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="38"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="118"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="198"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy">
            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy1">
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-42"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="38"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="118"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="198"/>
        </DoubleAnimationUsingKeyFrames>
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy1">
            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0"/>
            <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="1"/>
            <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0"/>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</Window.Resources>
<Window.Triggers>
    <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="Window">
        <BeginStoryboard x:Name="OnLoaded2_BeginStoryboard1" Storyboard="{StaticResource OnLoaded2}"/>
    </EventTrigger>
    <EventTrigger RoutedEvent="FrameworkElement.Loaded">
        <BeginStoryboard x:Name="OnLoaded2_BeginStoryboard" Storyboard="{StaticResource OnLoaded2}"/>
    </EventTrigger>
</Window.Triggers>

<Grid x:Name="LayoutRoot" Background="#FF00A7FF">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="VisualStateGroup">
            <VisualStateGroup.Transitions>
                <VisualTransition GeneratedDuration="0">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
                            <EasingDoubleKeyFrame KeyTime="0" Value="-42"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="38"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="118"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="198"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-42"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="38"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="118"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="198"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy1">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-42"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="38"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="118"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="198"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy1">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualTransition>
            </VisualStateGroup.Transitions>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.ColumnDefinitions>
        </Grid.ColumnDefinitions>
    <Grid x:Name="grid" Margin="10.333,32.333,-4.333,-26.333">
        <Ellipse x:Name="ellipse" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
            <Ellipse.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                    <SkewTransform/>
                    <RotateTransform Angle="79"/>
                    <TranslateTransform X="-42"/>
                </TransformGroup>
            </Ellipse.RenderTransform>
            <Ellipse.Fill>
                <RadialGradientBrush>
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White"/>
                </RadialGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
        <Ellipse x:Name="ellipse_Copy" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
            <Ellipse.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                    <SkewTransform/>
                    <RotateTransform Angle="79"/>
                    <TranslateTransform X="-42"/>
                </TransformGroup>
            </Ellipse.RenderTransform>
            <Ellipse.Fill>
                <RadialGradientBrush>
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White"/>
                </RadialGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
        <Ellipse x:Name="ellipse_Copy1" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
            <Ellipse.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                    <SkewTransform/>
                    <RotateTransform Angle="79"/>
                    <TranslateTransform X="-42"/>
                </TransformGroup>
            </Ellipse.RenderTransform>
            <Ellipse.Fill>
                <RadialGradientBrush>
                    <GradientStop Color="Black" Offset="0"/>
                    <GradientStop Color="White"/>
                </RadialGradientBrush>
            </Ellipse.Fill>
        </Ellipse>
        <TextBlock Margin="7.833,0,0,0" TextWrapping="Wrap" FontSize="26.667" Foreground="White" FontWeight="Bold"><Run FontFamily="Segoe UI Semibold" Text="Kirusoft"/><Run Text=" "/><Run FontFamily="Segoe UI Light" Text="Dev."/></TextBlock>
    </Grid>
</Grid>

4

1 回答 1

2

您无法将另一个 Wpf 窗口嵌入到 Wpf 窗口中,您需要创建一个UserControl. 过去,当我Window想要将 a 转换为 a时,我所做的是将 Xaml 中对的UserControl所有引用更改为. 在你的情况下,它看起来像这样。WindowUserControl

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    x:Class="WpfApplication2.UserControl1"
    x:Name="Logo"
    Width="300" Height="150">
    <UserControl.Resources>
        <Storyboard x:Key="OnLoaded1"/>
        <Storyboard x:Key="OnLoaded2">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0" Value="-42"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="38"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="118"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="198"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse">
                <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy">
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-42"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="38"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="118"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="198"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy">
                <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy1">
                <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-42"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="38"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="118"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="198"/>
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy1">
                <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
        <UserControl.Triggers>
            <EventTrigger RoutedEvent="Mouse.MouseEnter" >
                <BeginStoryboard x:Name="OnLoaded2_BeginStoryboard1" Storyboard="{StaticResource OnLoaded2}"/>
            </EventTrigger>
            <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                <BeginStoryboard x:Name="OnLoaded2_BeginStoryboard" Storyboard="{StaticResource OnLoaded2}"/>
            </EventTrigger>
        </UserControl.Triggers>

        <Grid x:Name="LayoutRoot" Background="#FF00A7FF">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="VisualStateGroup">
                    <VisualStateGroup.Transitions>
                        <VisualTransition GeneratedDuration="0">
                            <Storyboard>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="-42"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="38"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="118"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="198"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse">
                                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy">
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-42"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="38"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="118"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="198"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy">
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.3" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="ellipse_Copy1">
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="-42"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="38"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="118"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="198"/>
                                </DoubleAnimationUsingKeyFrames>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ellipse_Copy1">
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="1"/>
                                    <EasingDoubleKeyFrame KeyTime="0:0:1.9" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualTransition>
                    </VisualStateGroup.Transitions>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid.ColumnDefinitions>
            </Grid.ColumnDefinitions>
            <Grid x:Name="grid" Margin="10.333,32.333,-4.333,-26.333">
                <Ellipse x:Name="ellipse" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
                    <Ellipse.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                            <SkewTransform/>
                            <RotateTransform Angle="79"/>
                            <TranslateTransform X="-42"/>
                        </TransformGroup>
                    </Ellipse.RenderTransform>
                <Ellipse.Fill>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="White"/>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <Ellipse x:Name="ellipse_Copy" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
                <Ellipse.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                        <SkewTransform/>
                        <RotateTransform Angle="79"/>
                        <TranslateTransform X="-42"/>
                    </TransformGroup>
                </Ellipse.RenderTransform>
                <Ellipse.Fill>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="White"/>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <Ellipse x:Name="ellipse_Copy1" HorizontalAlignment="Left" Margin="-7.337,32.805,0,0" StrokeThickness="0" Width="15" RenderTransformOrigin="0.5,0.5" Height="15" VerticalAlignment="Top">
                <Ellipse.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="0.5" ScaleY="0.5"/>
                        <SkewTransform/>
                        <RotateTransform Angle="79"/>
                        <TranslateTransform X="-42"/>
                    </TransformGroup>
                </Ellipse.RenderTransform>
                <Ellipse.Fill>
                    <RadialGradientBrush>
                        <GradientStop Color="Black" Offset="0"/>
                        <GradientStop Color="White"/>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <TextBlock Margin="7.833,0,0,0" TextWrapping="Wrap" FontSize="26.667" Foreground="White" FontWeight="Bold"><Run FontFamily="Segoe UI Semibold" Text="Kirusoft"/><Run Text=" "/><Run FontFamily="Segoe UI Light" Text="Dev."/></TextBlock>
        </Grid>
    </Grid>
</UserControl>
于 2013-02-02T05:35:10.523 回答