Silverlight 中 PictureBox 的替代品是什么?
我的 Windows 窗体应用程序中有一个 PictureBox,我正在将我的应用程序转换为 Silverlight,我想知道 Silverlight 中 PictureBox 的替代品是什么,谢谢!
i have a PictureBox in my Windows Form application and i am in the process of converting my application to Silverlight and i would like to know what is the alternative of PictureBox in Silverlight, Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据您使用的 PictureBox 的功能,您可以只使用 Silverlight 中的图像 控件。
Depending on the functionality of the PictureBox you are using, you could just use the Image control in Silverlight.
在这种情况下,图像控件是您唯一的选择,但您应该小心,该控件仅支持 .jpg 和 .png 图像扩展名,对于其他格式,您必须创建或使用转换器
Image control is your only choice for this case, but you should be careful that this control just support .jpg and .png image extentions and for other formats you must create or use converters
您可能想要尝试的是 Viewbox 控件。然后,您可以在 Viewbox 内部放置图像。 Viewbox 的伟大之处在于,即使 VB 调整大小,您也始终可以一致地缩放内部的所有内容。或者,您可以使用 @Chris 指出的图像并提供尺寸限制和比例设置。
示例 XAML:
然后,您可以将 Viewbox 放置在 Stackpanel 或 Grid 中以实现正确的布局。希望这有帮助!
What you might want to try is the Viewbox control. Then, inside of the Viewbox you can place an image. The great thing about the Viewbox is that you can always scale everything inside consistently, even as the VB resizes. Or, you can use the Image as @Chris pointed out and provided size limits and a scale setting.
Sample XAML:
You could then place the Viewbox inside a Stackpanel or Grid to achieve proper layout. Hope this helps!