gpt4 book ai didi

silverlight - 如何在 Silverlight 应用程序中获取客户端大小?

转载 作者:行者123 更新时间:2023-12-01 11:09:54 24 4
gpt4 key购买 nike

我想获得运行我的 Silverlight 应用程序的浏览器窗口的大小?我试过以下几行,但它总是返回零!

public Page()
{
InitializeComponent();
Initialize();

}

public void Initialize()
{

WorldLimits.Y = Application.Current.Host.Content.ActualHeight;
WorldLimits.X = Application.Current.Host.Content.ActualWidth;

gameCore = new GameCore(this);
gameTime = DateTime.Now.TimeOfDay.TotalMilliseconds / 1000;

}

最佳答案

确保您正在获取事件处理程序中的值

public Page()
{
InitializeComponent();
App.Current.Host.Content.Resized += new EventHandler(Content_Resized);
}

void Content_Resized(object sender, EventArgs e)
{
this.Width = App.Current.Host.Content.ActualWidth;
this.Height = App.Current.Host.Content.ActualHeight;
}

关于silverlight - 如何在 Silverlight 应用程序中获取客户端大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1132858/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com