我有一个带有两个XAML/WPF窗口(从NavigationWindow派生)的应用程序,每个窗口包含一个父UserControl,其中放置了所有子控件.在其中一个窗口中,我想以像画中画电视的方式显示第二个窗口的内容(实际上只是父UserControl).通过这种方式,用户可以查看第一个窗口,并同时查看第二个窗口中发生的情况.注意,我不想要第二个窗口的UserControl的两个独立副本(这很容易),而是要在第一个窗口中镜像第二个窗口的内容.
这与Windows 7任务栏缩略图预览模糊地相似,所以我认为它必须是可行的.然而,理想情况下,我还希望能够与窗口中的窗口进行交互,就像我拉起原始窗口一样.
这与此问题类似,不同之处在于我只想从同一个应用程序中复制一个窗口,而不是整个桌面.也类似于这个问题,但我需要更多的手持,因为我不太熟悉C#/ WPF.一些代码片段会很棒.
先感谢您!
使用视觉画笔作为矩形的填充。
不过,您将无法与它交互...但这就是任务栏上预览缩略图的实现方式。
<Grid HorizontalAlignment="Left" Name="A" Height="100" Width="100">
<Grid.Background>
<SolidColorBrush Opacity="0" Color="White"/>
</Grid.Background>
<!-- Contents -->
</Grid>
<Rectangle Name="RA" VerticalAlignment="Top" Width="100" Height="100" HorizontalAlignment="Left" Stroke="Black">
<Rectangle.Fill>
<!-- Creates the reflection. -->
<VisualBrush AutoLayoutContent="True" Visual="{Binding ElementName=A}" ViewboxUnits="RelativeToBoundingBox" ViewportUnits="RelativeToBoundingBox" Stretch="Fill" AlignmentX="Left" AlignmentY="Top" Viewport="0,0,1,1" Viewbox="0,0,1,1" TileMode="None">
</VisualBrush>
</Rectangle.Fill>
</Rectangle>
Run Code Online (Sandbox Code Playgroud)
要进行交互,您必须将所有属性绑定到相同的屏幕,并使用布局转换来缩小它。
<StackPanel>
<Grid>
<TextBox Name="A"/>
</Grid>
<Grid>
<Grid.LayoutTransform>
<ScaleTransform CenterX=".5" CenterY=".5" ScaleX=".25" ScaleY=".25"/>
</Grid.LayoutTransform>
<TextBox Name="B" Text="{Binding ElementName=A, Path=Text, UpdateSourceTrigger=PropertyChanged}"/>
</Grid>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)