自动调整 Silverlight 3 应用程序大小

发布于 2024-09-02 19:51:05 字数 338 浏览 0 评论 0原文

我一直在尝试让 Silverlight 3 应用程序在将行添加到数据网格时自动调整大小。 我试过了 此示例 但我只是得到一个带有空内部异常的 System.ExecutionEngineException 。我认为这仅针对 Silverlight 2。 谁能告诉我如何在 Silverlight 3 中做到这一点?

对此的任何帮助将不胜感激。

I've been trying to get a Silverlight 3 application to automatically resize when rows are added to datagrids.
I've tried
this example
but I just get a System.ExecutionEngineException with a null inner exception. I think this is aimed at Silverlight 2 only.
Can anyone tell me how to do this in Silverlight 3?

Any help on this would be much appreciated.

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

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

发布评论

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

评论(1

止于盛夏 2024-09-09 19:51:05

我已经使用以下方法进行了此操作:

将以下 javascript 添加到包含 silverlight 对象的页面:

 function ResizeObject(height) {
        var host = document.getElementById("silverlightControlHost");
        host.style.height = height + "px";
    } 

将以下内容添加到您的 silverlight 代码隐藏中:

public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(Page_Loaded);
        this.yourRootElement.LayoutUpdated += new EventHandler(LayoutRoot_LayoutUpdated);
    }

    private void LayoutRoot_LayoutUpdated(object sender, EventArgs e)
    {
        HtmlPage.Window.Invoke("ResizeObject", new object[] { this.yourRootElement.RenderSize.Height });
    }

请注意,“ResizeObject”指的是网页上的 javascript 函数。

I 've got this working with the following:

Add the following javascript to the page with your silverlight object:

 function ResizeObject(height) {
        var host = document.getElementById("silverlightControlHost");
        host.style.height = height + "px";
    } 

Add the following to your silverlight codebehind:

public MainPage()
    {
        InitializeComponent();
        this.Loaded += new RoutedEventHandler(Page_Loaded);
        this.yourRootElement.LayoutUpdated += new EventHandler(LayoutRoot_LayoutUpdated);
    }

    private void LayoutRoot_LayoutUpdated(object sender, EventArgs e)
    {
        HtmlPage.Window.Invoke("ResizeObject", new object[] { this.yourRootElement.RenderSize.Height });
    }

Note that "ResizeObject" refers to the javascript function on your webpage.

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