rob*_*rtk 0 xaml windows-phone winrt-xaml win-universal-app windows-10
我正在尝试为Windows 10开发一个应用程序.但是对于全新的屏幕显示,我似乎无法弄清楚如何使元素适合设备屏幕的当前大小.
例如,如果您调整窗口大小,我希望TextBlock适合窗口的宽度.我已经尝试过ViewBox,VariableSIzedWrapGrid等等,但似乎没有什么能解决我的问题.有谁知道?
更新:这是我试图适应下面窗口大小的搜索框.网格填充整个窗口,如果我在其上放置背景颜色,也会填充RelativePanel.但SearchBox拒绝拉伸...我不希望搜索框的大小缩放,只是它的宽度适合窗口/设备宽度.
<!-- SEARCH GRID -->
<Grid Canvas.ZIndex="5" x:Name="GridSearchPackage" HorizontalAlignment="Stretch" Visibility="Visible" Opacity="0.85" Background="White">
<RelativePanel HorizontalAlignment="Stretch" Margin="5,5,0,0" >
<Button x:Name="ButtonBackSearchGrid" Height="36" Width="36" FontSize="10" Margin="0,7,5,0"
Style="{StaticResource BackButtonStyle}"
Click="ButtonBackSearchGrid_Click"
AutomationProperties.Name="Back"
AutomationProperties.AutomationId="BackButton"
AutomationProperties.ItemType="Navigation Button" BorderBrush="Black" BorderThickness="3">
<FontIcon x:Name="backButtonIcon" FontWeight="Bold" FontSize="20" Foreground="{StaticResource AppDarkBlueColor}" Glyph="" />
</Button>
<TextBlock x:Name="TextBlockPopupSearchTitle" RelativePanel.RightOf="ButtonBackSearchGrid" Foreground="{StaticResource AppDefaultBlueColor}" Text="Search XZY" FontSize="34"/>
<SearchBox FontSize="20" RelativePanel.Below="TextBlockPopupSearchTitle" HorizontalAlignment="Stretch" PlaceholderText="search" Margin="0,10,0,0" QuerySubmitted="SearchBox_QuerySubmitted" QueryText="{Binding SearchText, Mode=TwoWay}"/>
</RelativePanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
小智 13
当你使用RelativePanel
,你可能需要设置AlignLeftWithPanel
和AlignRightWithPanel = true
使现有的整个水平空间的TextBlock
(类似地AlignTopWithPanel
,AlignBottomWithPanel=true
对于垂直).大多数UIElements
都具有HorizontalAlignment
/ VerticalAlignment = Stretch
作为默认值,但您可能还需要明确设置它,以确保TextBlock
在屏幕上拉伸的实际视觉效果.
调整窗口大小时,元素将使用上述设置自动调整大小.您不需要使用ViewBox
此处来实现此目的.
归档时间: |
|
查看次数: |
5401 次 |
最近记录: |