Silverlight 中最大的问题是什么? [英] What are the biggest gotchas in Silverlight?

查看:29
本文介绍了Silverlight 中最大的问题是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直在 Silverlight 工作,我慢慢发现开发虽然简单,但仍有一两个令人讨厌的问题潜伏在阴影中.

I've been working in Silverlight recently and I've slowly been discovering that as simple as it can be to develop, there are one or two annoying gotchas that lurk in the shadows.

考虑到其中一些对我来说是多么困难,我认为将它们列在 SO 上可能有用,以便其他人从中受益.我确信我遇到的那些与其他人的经历相比不算什么,我想尽量避免任何其他令人讨厌或耗时的惊喜.

Considering how difficult some of these have been to track down for me, I thought it might be useful to list them here on SO for others to benefit from. I'm sure the ones I have encountered are nothing compared to the experience of others and I'd like to try and avoid any other nasty or time consuming surprises.

那么,你有什么?

更新
我已经更新了它以涵盖一般的 Silverlight.因此,请在响应时提供与问题相关的版本或列表版本.对于所有没有版本的人,请假设 Silverlight 2.0,因为这是原始问题中的情况.

Update
I've updated this to cover Silverlight in general. Therefore, please provide a version or list versions to which the gotcha relates when responding. For all those without a version, please assume Silverlight 2.0 as this was the case in the original question.

推荐答案

我经历过的两个是:

要使 Silverlight 与托管在不同域上的 Web 服务一起使用,服务器需要 跨域策略文件.这可以采用两种格式:

For Silverlight to work with Web Services that are hosted on a different domain, the server needs a cross domain policy file. This can take two formats:

  • clientaccesspolicy.xml
  • crossdomain.xml

我无法让前者正常工作,但后者可以正常工作(Flash 使用第二个,而我相信第一个是特定于 ASP 的,尽管我无法让它在 ASP.NET 2.0 服务器下工作,所以它可能是 3.5 特定的).

I couldn't get the former to work properly but the latter worked (Flash uses the second one whereas I believe the first is specific to ASP though I couldn't get it working under an ASP.NET 2.0 server, so it may be 3.5-specific).

Silverlight 2.0 组合框控件仅在首次显示时调整其下拉区域的大小.因此,它的大小基于其列表中的初始项目.这意味着 2 个项目将为您提供 2 个项目的高下拉列表,即使列表增加到 200.解决此问题的唯一方法似乎是每次项目更改时用全新的控件替换组合.

The Silverlight 2.0 combobox control only sizes its dropdown area once, when it is first shown. It therefore bases it's size on the initial items in its list. That means 2 items will give you a 2 item high dropdown, even when the list increases to 200. The only way around this appears to be to replace the combo with a whole new control each time the items change.

请注意,将 Height 属性或 MaxHeight 属性设置为导致项目出现在下拉列表初始显示中的列表之外的值将导致缺少垂直滚动条,因此无法访问列表中的项目你的清单.我找到的唯一解决方案是使用 MinHeight 属性至少在所有用途中都有一个合适的高度,如果项目超过最小高度,就让它更大.

Note that setting the Height property or the MaxHeight property to a value that leads to items appearing off the list in the initial display of the dropdown will lead to an absence of a vertical scrollbar and therefore, an absence of access to items in your list. The only solution I found to that was to use the MinHeight property to at least have a decent height for all uses and just let it be bigger if the items exceed that minimum height.

此外,当您调整浏览器窗口大小时,无论您是否使用 MinHeight,然后下拉组合列表或在其可见时调整大小,这都会不可逆转地减小下拉列表的大小.

Also, when you resize the browser window, regardless of whether you use MinHeight or not, and then either dropdown the combo list or you resize while it is visible, this can irreversably decrease the size of the dropdown.

这是组合问题的一个非常好的解决方案,感谢 markti.

这篇关于Silverlight 中最大的问题是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆