嗨,目前我正在使用带有图像和两个按钮的网格来在我的 WP7 应用程序中显示自定义消息框,其可见性首先折叠。一切工作正常,但当其可见性可见时,我必须禁用页面后面的所有控件。因此,启用/禁用后面的大量控制是相当大的开销。
对于我的要求有更好的解决方案吗:(1)显示一个包含图像和两个按钮或文本框的消息框,(2)它应该出现在页面中间。
提前致谢!!
最佳答案
您可以使用内置Popup control具有由 Kent Boogaart 编写的附加行为,因此它的行为类似于带有 PlacementTarget
和 Placement
的 WPF Popup 控件:
<Popup b:PopupPlacement.PlacementTarget="{Binding ElementName=someElement}">
<b:Popup.PreferredOrientations>
<b:PopupOrientationCollection>
<b:PopupOrientation Placement="Top" HorizontalAlignment="Center"/>
<b:PopupOrientation Placement="Bottom" HorizontalAlignment="Center"/>
<b:PopupOrientation Placement="Right" VerticalAlignment="Center"/>
<b:PopupOrientation Placement="Right" VerticalAlignment="TopCenter"/>
</b:PopupOrientationCollection>
</b:Popup.PreferredOrientations>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0">My popup's contents</TextBlock>
<Image Grid.Row="1" .... />
</Grid>
</Popup>
关于c# - WP7 中带有图像的消息框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7792620/