【发布时间】:2015-09-12 11:28:24
【问题描述】:
我正在尝试使用StackPanel 控件来显示一些概览选项。当MinWindowWidth 大于768px 时,我需要使用 20% 的窗口宽度进行此控制。当它在移动设备上运行时,我需要控件来填充屏幕的宽度。
我按照question 中的建议尝试设置百分比值。但是,我收到错误 - “* 字符串无法转换为长度”。
这是我的 XAML -
<StackPanel x:Name="OverviewStack">
<RelativePanel>
<StackPanel Margin="10" x:Name="User" Orientation="Horizontal">
<Ellipse Margin="5" Width="50" Height="50">
<Ellipse.Fill>
<ImageBrush>
<ImageBrush.ImageSource>
<BitmapImage UriSource="Assets/insp.jpg" />
</ImageBrush.ImageSource>
</ImageBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock Margin="5" VerticalAlignment="Center" Text="Ajay Kelkar" />
</StackPanel>
<StackPanel Margin="10" x:Name="Options" Orientation="Vertical">
<TextBlock Margin="5" Text="Sample text" />
</StackPanel>
</RelativePanel>
</StackPanel>
在 UWP 中不能使用百分比值吗?还是我做错了什么?
【问题讨论】:
-
改用
Grid。 -
@JustinXL 我会试试的。我需要它来使用状态触发器
-
@JustinXL 你能把它作为答案发布吗?我已经切换到使用网格