silverlight 中的解决问题

发布于 2024-08-20 13:21:39 字数 116 浏览 7 评论 0原文

你好,我需要在 silverlight 应用程序中有一个与分辨率无关的 UI。它会隐式支持还是应该在 ScaleTransform 后面的代码中注意?

它也支持多种浏览器吗?

提前致谢。

HI, i need to have a resolution independant UI in silverlight application. Will it support implicitly or should it be taken care in code behind doing ScaleTransform ?

will it support multiple browsers as well ?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的黑色迷你裙 2024-08-27 13:21:39

您可以使用Silverlight Toolkit 中的ViewBox 控件来进行比例变换。它将适用于所有支持的浏览器。

您还可以将 UserControl 的宽度和高度设置为“自动”(或删除它们),然后让 UI 拉伸(但不调整大小)到您设置的规则(通常使用网格控件)。

You can use The ViewBox control in the Silverlight Toolkit to do the scale transforming. It will work on all supported browsers.

You can also set the UserControl width and height to Auto (or remove them) and then have your UI stretch (but not resize) to rules that you set up (typically with a Grid control).

不一样的天空 2024-08-27 13:21:39

好的,我想我将概述您可以利用 Silverlight 允许指定大小的隐式方法的所有方法。

如果您在控件中使用 VerticalAlignment 选项的 Stretch 设置定义任何内容:

UIElement 将拉伸以占据其父控件中的所有可用空间。诸如此类的另一个设置是定义网格列宽或行高,如下所示:

这将占用屏幕上的所有可用空间。

您可以以比率形式增加网格的列和行:


这将使第二行每增长 2px,第一行的高度就增长 3px。

然后您可以使用诸如 Auto

这样

的选项,这将根据大小要求增长 UIElement。如果元素的子元素需要更大的大小,则该元素将占用更多的屏幕空间。

最后:

这些是固定值,并确保在给定任何分辨率下,元素占用的宽度不会超过 400 像素,但不会小于 200 像素。它还表明元素的高度应始终为 100px。这对于您不希望随着分辨率变化而增大或缩小的按钮等元素非常有用。

最后,您可能希望在整个事物周围包装一个 ScrollViewer,只是为了确保可以滚动到屏幕外的元素。当您的视图需要的空间超过屏幕上的可用空间或将元素设置为自动时,就会发生这种情况。

Okay, I figured I will outline all the methods that you can make use of the implicit methods that Silverlight allow for specifying sizing.

If you define anything using the Stretch setting for VerticalAlignment option in a control:

<TextBox Grid.Column="0" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>

The UIElement will stretch to take up all the space available to it in its parent control. Another setting such as this is to do something like defining a grid column width or row height like this:

<ColumnDefinition Width="*"/>

This will take up all the space available on the screen.

You can grow columns and rows of the grid in a ratio form:

<RowDefinition Height="3*"/>
<RowDefinition Height="2*"/>

This will grow the height of the first row by 3px for each 2px that the second one grows.

Then you can have options such as Auto

<ColumnDefinition Width="Auto"/>

This will grow the UIElement according to size requirements. If a child of the element requires more size, the element will take up more screen space.

And finally:

<TextBox Grid.Column="1" Grid.Row="0" Height="100" MinWidth="200" MaxWidth="400" x:Name="text"/>

These are fixed values and ensures that given any resolution that the element will not take up more than 400px in width but no less than 200px. It also indicates that the height of the element should always be 100px. This is useful for elements such as buttons etc. which you do not want to grow or shrink as the resolution changes.

Finally, you will probably want to wrap a ScrollViewer around the whole thing, just to ensure that elements off the screen can be scrolled to. This can happen when your view requires more space than available on the screen or have elements set to Auto.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文