如何从 WPF 应用程序将用户控件弹出到全屏?
有没有办法将用户控件/控件(例如 Grid、ViewBox 或自定义控件)从 WPF 应用程序弹出到全屏或模态窗口?当您按 esc 时,将其放回原来的位置。
一个场景可能是您有一个 WPF 应用程序,其中包含一个具有两列的网格。第一个显示图像预览,第二个显示图像列表。当您双击图像预览时,它会弹出全屏或模式对话框。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Content="Left" Grid.Column="0" />
<GridSplitter HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Grid.Column="1" Width="5">
<ListBox Content="Right" Grid.Column="2" />
</Grid>
我已经在 www 上寻找答案,但没有成功。 任何想法或示例或链接将不胜感激。
Is there a way to pop a usercontrol/control let say a Grid,ViewBox or custom control from a WPF application to fullscreen or to a modal window? And put it back to it's orginal place when you press esc.
A Scenario could be that you have a WPF application consisting of a grid with two columns. Where the first shows a image preview and the second one shows list of images. When you double click the image preview it pops to fullscreen or as a modal dialog.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Content="Left" Grid.Column="0" />
<GridSplitter HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Grid.Column="1" Width="5">
<ListBox Content="Right" Grid.Column="2" />
</Grid>
I have scouted the www for a answer without any success.
Any Ideas or examples or links would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法按照 MSDN 此处。弹出对话框最多可以覆盖全屏的 75%
You cannot cover full screen as explained by MSDN here. Maximum a pop up dialog can cover 75% of the full screen
上周我问了一个有点类似的问题。可以在此处查看。
我最终使用了一个包裹面板,其高度和宽度设置为自动,并包含一个控件列表。 (我使用自定义逻辑来计算每个控件的高度/宽度)。
当用户选择一个控件时,我将所有其他控件的可见性设置为 false。这使得所选控件现在看起来是全屏的。
当用户取消选择时,循环遍历所有控件并将它们设置为再次可见。
如果需要网格并且您不想使用自定义逻辑。您始终可以将图像放在表单上其他控件的顶部,并将其默认可见性设置为 false。您可以将图像源属性绑定到所选项目属性。那么当selection不为null时图片可以显示吗?
I asked a somewhat similar question last week. Which can be seen here.
I ended up using a wrap panel which has its height and width set to auto and contains a list of controls. (I use custom logic to calculate the height/width of each control).
When a user selects a control, I set the visibility to false on all the other controls. Which makes it appear that the selected control is now full screen.
When the user cancels the selection, loop through all the controls and set them to be visible again.
If a grid is needed and you do not want to use custom logic. You could always put an image on top of the other controls on the form and have its default visibility to false. you could bind the image source property to the selected item property. Then the image can be displayed when the selection is not null?