我在这里浏览了许多主题,并通过谷歌搜索了信息,但没有找到与我的问题相关的任何内容。
我想要做的是拥有它,以便当用户启动应用程序时,主窗口(不是 MDI)将打开并显示四个图像框,每个图像框显示当他们单击它时将打开的表单图像。一旦选定的表单打开并进行更改,如果单击最小化/关闭表单,它将(看似)最小化到图像框中,显示表单在缩略图视图中的实时图像。
我的问题是,如何将表单制作成图像,以便可以将该图像用作图像框中的缩略图?
另外...有人可以向我指出一些资源的方向,这些资源将帮助我弄清楚如何将“最小化”动画设置到图像框中吗?
我不会要求任何人为我做我的工作,因为我想自己学习,但我有点卡住了。
最后,我不确定这涉及到什么,所以我不知道该给这篇文章贴什么标签。我会添加标签,以便其他人可以找到此信息。
EDIT:抱歉,它是在 WPF 中。不确定会有什么不同。我对 WPF 还不是特别有经验。
您可以使用 VisualBrush,这里是一个按钮的快速示例,其背景设置为堆栈面板的缩小版本。
<DockPanel>
<StackPanel x:Name="myRect" >
<TextBox Text="MyTexasdfasdfasdfasdfasdft" Height="50" />
<CheckBox IsChecked="True" />
<Rectangle Fill="Red" Width="100" Height="100" />
</StackPanel>
<Button>
<Button.Background>
<VisualBrush TileMode="None" Viewport="0,0,1,1" Visual="{Binding ElementName=myRect}" >
<VisualBrush.Transform>
<ScaleTransform ScaleX="0.3" ScaleY="0.3" />
</VisualBrush.Transform>
</VisualBrush>
</Button.Background>
</Button>
</DockPanel>
编辑:虽然此解决方案可以复制屏幕上的内容,但当屏幕上的内容被隐藏或删除时,VisualBrush 也会如此。
为了保留图像,需要将控件呈现为位图。这可以通过 RenderTargetBitMap 来完成
// CenterControl is the target to render, ShowControl is the control to render the CenterControl onto.
var rtb = new RenderTargetBitmap((int)CenterControl.ActualWidth, (int)CenterControl.ActualHeight, 96, 96,
PixelFormats.Pbgra32);
rtb.Render(CenterControl);
var bgBrush = new ImageBrush(rtb) {Transform = new ScaleTransform(0.1, 0.1)};
ShowControl.Background = bgBrush;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)