Win Form用户控件在WPF xaml中不可见

时间:2014-04-01 22:07:25

标签: wpf winforms xaml

我有一个xaml启动表单,其中我正在尝试托管一个Windows窗体控件,这是一个显示产品名称/许可证内容的启动画面..这是我用来托管用户控件但是它的xaml代码根本不可见。不是在设计师,也不在我实际运行应用程序的时候......这有什么不对吗?

<Window
    x:Class="StartupWindow"
    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"
    xmlns:wf="clr-namespace:namespace;assembly=assemblyName"
    mc:Ignorable="d" x:Name="splashWindow"
    WindowStyle="None" ResizeMode="NoResize" Width="500" Height="400"
    AllowsTransparency="True" Background="Transparent" ShowInTaskbar="False"            Topmost="True"
>
<Window.Triggers>
    <EventTrigger RoutedEvent="Window.Unloaded">
        <BeginStoryboard>
            <Storyboard x:Name="board">
                <DoubleAnimation Storyboard.TargetName="splashWindow"   Storyboard.TargetProperty="Opacity" From="1.0" To="0" Duration="0:0:1.5" />
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</Window.Triggers>
<Grid x:Name="LayoutRoot">
    <Grid x:Name="Splash" Width="450" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,100,0,0">
        <Grid x:Name="Back">
            <Grid.Effect>
                <DropShadowEffect ShadowDepth="1" Direction="-90" BlurRadius="10" Opacity="0.25"/>
            </Grid.Effect>
            <Border Background="Black" CornerRadius="3" Opacity="0.15"/>
            <Border CornerRadius="2" Margin="1" Background="#229C47"/>
        </Grid>
        <Grid x:Name="Content_Area" Margin="12">
            <Image x:Name="Image" Stretch="None" Height="99" Grid.Row="1"/>
            <TextBlock x:Name="Info" TextWrapping="Wrap" Text="Starting..." Grid.Row="2" Margin="12,12,12,0" Foreground="White"/>
        </Grid>
    </Grid>
    <WindowsFormsHost Height="325" Name="splashControl" Margin="54,12,64,24" Width="460" HorizontalAlignment="Center" Background="Transparent">
      <wf:SplashControl />
    </WindowsFormsHost>
 </Grid>
</Window>

1 个答案:

答案 0 :(得分:1)

我现在正在解决同样的问题。

此处的问题是窗口的AllowsTransparency="True",与使用WindowsFormsHost显示WinForms控件不兼容。

看看here

相关问题