Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WP8:在Webbrowser控件中将图像宽度设置为设备宽度_C#_Html_Css_Windows Phone 8 - Fatal编程技术网

C# WP8:在Webbrowser控件中将图像宽度设置为设备宽度

C# WP8:在Webbrowser控件中将图像宽度设置为设备宽度,c#,html,css,windows-phone-8,C#,Html,Css,Windows Phone 8,我有一个使用WebBrowser控件的WP8应用程序。在控制范围内,我正在加载一个图像,我希望它正好是手机的宽度。我对此有意见 在代码中,我得到屏幕宽度和比例因子: var initalWidth = Application.Current.Host.Content.ActualWidth; var factor = Application.Current.Host.Content.ScaleFactor / 100.0; var screenWidth = (initalWidth / fac

我有一个使用WebBrowser控件的WP8应用程序。在控制范围内,我正在加载一个图像,我希望它正好是手机的宽度。我对此有意见

在代码中,我得到屏幕宽度和比例因子:

var initalWidth = Application.Current.Host.Content.ActualWidth;
var factor = Application.Current.Host.Content.ScaleFactor / 100.0;
var screenWidth = (initalWidth / factor).ToString();
然后,我将screenWidth传递给我的html,该html加载到设置图像宽度的浏览器控件中

这就是我看到的行为:

Lumia 520

initial width= 480
factor = 1
screenWidth = 480
initial width= 480
factor = 1.6
screenWidth = 300
理想结果:图像正好是手机的宽度

Lumia 920

initial width= 480
factor = 1
screenWidth = 480
initial width= 480
factor = 1.6
screenWidth = 300
不期望的结果:图像对于屏幕来说太小了约80像素。

我不明白为什么它能在520上工作而不能在920上工作。我做错什么了吗

在我的HTML代码中,我使用:

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

我不确定你想要什么。因为你得到了正确的东西?如果您希望它们以像素填充相同的空间,这就是现在正在发生的事情。如果希望它们填充相同的相对空间,则不应使用scalefactor`?

我希望我的图像正好与手机的宽度相同。我上面的方法对Lumia 520实现了这一点,但对Lumia 920却没有。产生的图像宽度小于屏幕宽度。正是因为比例。你要做的是使它的尺寸相对相同。即,填充多个像素。通过不使用刻度,一切都应该是好的不幸的是,这不是我在Lumia 920上看到的。报告的屏幕宽度为480,缩放宽度为300,但这些都不起作用。图像宽度必须设置为380左右,以精确填充屏幕宽度。我不明白如何获得这个数字。通过反复试验,我得到了380。在我的lumia 920上是480,并且已经在三种不同的设备上进行了测试。它是一个特定的Microsoft单元,因此可以在所有设备上扩展。如果你想让你的用户界面适合一个分辨率,那么就使用比例因子。