需要进一步帮助我的应用程序的宽度适当适应 [英] Need further help in getting the width of my app to properly adapt

查看:58
本文介绍了需要进一步帮助我的应用程序的宽度适当适应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


早些时候我问过  广告的尺寸有多大?我得到了很好的反馈,但是在我的Lumia 950上运行我的应用程序时仍然遇到
a问题。我有一个按钮,当显示器处于宽屏模式时,应该是在右边的只有页面上的文本框。但是当显示器很窄时,它仍然显示在右侧。我希望它出现在
下的文本框中。这是相关的XAML:

< VisualStateManager.VisualStateGroups> 
< VisualStateGroup>
< VisualState x:Name =" NarrowLayout">
< VisualState.StateTriggers>
< AdaptiveTrigger MinWindowWidth =" 0" />
< /VisualState.StateTriggers>
< VisualState.Setters>
< Setter Target =" TheTextBox.Margin"值= QUOT; 10,20,10,0" />
< Setter Target =" ConvertButton。(RelativePanel.Below)"值= QUOT; TheTextBox" />
< Setter Target =" ConvertButton。(RelativePanel.AlignLeftWith)"值= QUOT; TheTextBox" />
< Setter Target =" ConvertButton.Margin"值= QUOT; 10,5" />
< Setter Target =" MyAdControl.Width"值= QUOT; 320" />
< Setter Target =" MyAdControl.Height"值= QUOT; 50" />
< /VisualState.Setters>
< / VisualState>
< VisualState x:Name =" WideLayout">
< VisualState.StateTriggers>
< AdaptiveTrigger MinWindowWidth =" 350" />
< /VisualState.StateTriggers>
< VisualState.Setters>
< Setter Target =" ConvertButton.Margin"值= QUOT; 5,20,5,5" />
< Setter Target =" ConvertButton。(RelativePanel.RightOf)"值= QUOT; TheTextBox" />
< Setter Target =" MyAdControl.Width"值= QUOT; 728" />
< Setter Target =" MyAdControl.Height"值= QUOT; 90" />
< /VisualState.Setters>
< / VisualState>
< / VisualStateGroup>
< /VisualStateManager.VisualStateGroups>

和FWIW,这是AdControl的XAML:

< UI:AdControl ApplicationId = QUOT; my123321id" 
AdUnitId =" 123454321"
Name =" MyAdControl"
高度="250"
Width =" 300"
Horizo​​ntalAlignment =" Center"
VerticalAlignment =" Bottom"
Grid.Row =" 1" />




我没什么好看的,所以我希望别人会看到我遗失的明显事实。


解决方案

嗨Rod,


您是否正在尝试检测手机处于横向模式还是纵向模式?


如果是,您可以尝试使用
展示信息
。您可能会检测到"DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;";或"DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;" ,然后让UI
布局发生变化。


最好的问候,


Annievia



Earlier I asked What are good sizes for ads? in this forum. I've gotten good feedback, but am still experiencing a problem when running my app on my Lumia 950. I've got a button that, when the display is in wide mode, is supposed to be to the right of the only textbox on the page. But when the display is narrow, it still appears to the right. I want it to appear under the textbox. Here's the relevant XAML:

<VisualStateManager.VisualStateGroups>
	<VisualStateGroup>
		<VisualState x:Name="NarrowLayout">
			<VisualState.StateTriggers>
				<AdaptiveTrigger MinWindowWidth="0" />
			</VisualState.StateTriggers>
			<VisualState.Setters>
				<Setter Target="TheTextBox.Margin" Value="10,20,10,0" />
				<Setter Target="ConvertButton.(RelativePanel.Below)" Value="TheTextBox" />
				<Setter Target="ConvertButton.(RelativePanel.AlignLeftWith)" Value="TheTextBox" />
				<Setter Target="ConvertButton.Margin" Value="10,5" />
				<Setter Target="MyAdControl.Width" Value="320" />
				<Setter Target="MyAdControl.Height" Value="50" />
			</VisualState.Setters>
		</VisualState>
		<VisualState x:Name="WideLayout">
			<VisualState.StateTriggers>
				<AdaptiveTrigger MinWindowWidth="350" />
			</VisualState.StateTriggers>
			<VisualState.Setters>
				<Setter Target="ConvertButton.Margin" Value="5,20,5,5" />
				<Setter Target="ConvertButton.(RelativePanel.RightOf)" Value="TheTextBox" />
				<Setter Target="MyAdControl.Width" Value="728" />
				<Setter Target="MyAdControl.Height" Value="90" />
			</VisualState.Setters>
		</VisualState>
	</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

And FWIW, here's the XAML for the AdControl:

<UI:AdControl ApplicationId="my123321id"
			  AdUnitId="123454321"
			  Name="MyAdControl"
			  Height="250"
			  Width="300"
			  HorizontalAlignment="Center"
			  VerticalAlignment="Bottom"
			  Grid.Row="1" />


Nothing stands out to me, so I'm hoping someone else will see the obvious that I'm missing.

解决方案

Hi Rod,

Are you trying to detect if the phone is in landscape mode or portrait mode?

If so, you could try using the DisplayInformation. You might detect if "DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;" or "DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;" , and let UI layout changes happen after that.

Best Regards,

Annievia


这篇关于需要进一步帮助我的应用程序的宽度适当适应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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