8

WinForms アプリケーションにオーバーレイしたい WPF コントロールがあります。そこで、次の WPF オブジェクトを表示できる Element Host を忠実に作成しました。

<UserControl x:Class="LightBoxTest.LightBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300" Background="Transparent">
    <Grid Name="dialogHolder" Background="Transparent" Opacity="1">
        <Rectangle Name="rectangle1" Stroke="White" Fill="Black" RadiusX="10" RadiusY="10" Opacity="0.5" />
        <StackPanel Name="stackPanel1" Background="Transparent" Height="300" VerticalAlignment="Top">
            <Rectangle Name="spacer" Opacity="0" Stroke="Gray" Fill="White" RadiusX="10" RadiusY="10" Height="100" Width="300" />
            <Grid Height="100" Name="contentHolder" Width="250">
                <Rectangle Name="dialog" Stroke="Gray" Fill="White" RadiusX="10" RadiusY="10" Height="100" Width="250" />
            </Grid>
        </StackPanel>
    </Grid>
</UserControl>

問題は、WinForm フォームのコントロールがレンダリングされず、WPF が画面上でそれらを消去することです。

要素ホストは次のように作成されます。

dialogHost = new ElementHost(); 
dialogHost.Child = dialog;
dialogHost.BackColorTransparent = true;
dialogHost.BringToFront();  
dialogHost.Show();

私がしなければならないことはありますか?

Winforms で透過的な WPF コントロールを表示することに関する既知の問題はありますか?

役立つ記事はありますか?

注:この質問はこの質問に関連しています

4

4 に答える 4

2

これを読む必要があります:ElementHostを使用するときにwpfコントロールをロードする前に黒い背景を 表示するだけです(クールではありませんが機能します)

于 2012-01-17T20:15:01.633 に答える
0

That seems like the interop airspace problem.

于 2009-06-01T20:55:56.677 に答える
-1

すでにお試しになっていると思いますが、ユーザー コントロールで不透明度を設定してみてはいかがでしょうか。

于 2009-06-01T20:51:57.700 に答える