WPF 窗体设置AllowsTransparency=true是 panel视频不能显示

 AllowsTransparency=true是加载winform:panel,控件不显示:原因窗体的逻辑和渲染冲突

 

 <WindowsFormsHost  x:Name="wfh"  Grid.Row="1" Grid.Column="1"  Margin="10,30,10,30" Background="Transparent"
                             Width="{Binding ElementName=grid,Path=ActualWidth}"
                              Height="{Binding ElementName=grid,Path=ActualHeight}"
                           Visibility="Hidden">
            <winform:Panel x:Name="Panel_video" Dock="Fill"/>
  </WindowsFormsHost>

 

解决:添加Popup将控件至于顶层  Popup ,并且AllowsTransparency="False"

      <Popup  Grid.Row="2"  Placement="Bottom" Height="190" Width="400"  VerticalOffset="10"  HorizontalOffset="-40" IsOpen="True" StaysOpen="True" AllowsTransparency="False">
                        <WindowsFormsHost  x:Name="wfHost"
                                       Visibility="Visible" Background="#e0e0e0" >
                            <wf:Panel Dock="Fill" BorderStyle="None"/>
                        </WindowsFormsHost>
                    </Popup>
                

posted @ 2020-05-26 17:23  无限环  阅读(976)  评论(0编辑  收藏  举报