【发布时间】:2017-08-04 11:36:45
【问题描述】:
我正在尝试在 Template 10 UWP Hamburger 模板应用程序中创建一个绘图表面,背景中有一个模板图像。有没有办法强制主视觉空间不可滚动?当我使用以下 XAML 时,当我将应用程序窗口拉得更宽时,图像会从屏幕上展开。
<!-- content -->
<StackPanel EntranceNavigationTransitionInfo.IsTargetElement="True"
Padding="12,8,0,0"
RelativePanel.AlignBottomWithPanel="True"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.Below="pageHeader">
<StackPanel Orientation="Horizontal">
<ComboBox Name="TemplateComboBox" ItemsSource="{x:Bind _templates}" SelectionChanged="TemplateComboBox_SelectionChanged" PlaceholderText="Select a template...">
<ComboBoxItem Content="{Binding}" />
</ComboBox>
<TextBlock x:Name="stateTextBox"
Margin="16,0,0,0"
Text="Current Visual State" />
</StackPanel>
<Grid Name="DrawingGrid" Margin="0,5,5,5" >
<Image Name="TemplateImage" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Stretch="Uniform" />
</Grid>
</StackPanel>
代码隐藏中有代码可以在组合选择更改时设置图像源。我只是想让图像拉伸到当前的可视区域。
sigh 还没开始接触 Ink :(
【问题讨论】:
-
如何设置 Image Stretch="UniformToFill" 在您的情况下工作?
-
它实际上并没有改变输出。 Image 控件拉伸以允许它“显示”整个位图,同时保留纵横比。我说“显示”,因为大部分都在视口之外,所以看不到。我添加了一些额外的调试信息,在笔记本电脑上全屏显示,页面(包括标题栏等)的 ActualHeight 为 897,而 Image 控件的 ActualHeight 为 2802。它只会真正显示大约 870 个。跨度>
标签: c# xaml uwp template10