2 回答
TA贡献1824条经验 获得超5个赞
如果您明确设置页面的宽度,它将永远不会拉伸:
删除Width="600",或者您可以设置MinWidth="600"。
<Page
x:Class="Stupendous_Styles_Challenge.Donuts"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Stupendous_Styles_Challenge"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" MinWidth="600">
<Page.Resources>
<Style TargetType="TextBlock" x:Key="myTextBlockStyle">
<Setter Property="FontSize" Value="24" />
<Setter Property="Margin" Value="10, 0, 0, 0" />
</Style>
TA贡献1811条经验 获得超6个赞
我认为这可能会解决问题,这是 donuts.xaml 的编辑版本:
<Page
x:Class="Stupendous_Styles_Challenge.Donuts"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Stupendous_Styles_Challenge"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="600">
<Page.Resources>
<Style TargetType="TextBlock" x:Key="myTextBlockStyle">
<Setter Property="FontSize" Value="24" />
<Setter Property="Margin" Value="10, 0, 0, 0" />
</Style>
<Style TargetType="Slider" x:Key="mySliderStyle">
<Setter Property="Width" Value="200" />
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Maximum" Value="24" />
<Setter Property="Minimum" Value="0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</Page.Resources>
<Grid Background="Red" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="200"/>
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Source="Assets/white-logo.png" Height="200" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Original Glazed Count: " Style="{StaticResource myTextBlockStyle}"/>
<Slider Grid.Column="1" Style="{StaticResource mySliderStyle}" />
<TextBlock Grid.Row="1" Text="Speedway Special Count: " Style="{StaticResource myTextBlockStyle}" />
<Slider Grid.Column="1" Grid.Row="1" Style="{StaticResource mySliderStyle}" />
</Grid>
</Grid>
在
<Grid Background="Red" HorizontalAlignment="Stretch">
部分:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
我认为问题在于框架内的网格没有占用它可以获得的空间并且具有固定的宽度,添加了 columndefinition 它确实占用了它所能占用的所有空间。
- 2 回答
- 0 关注
- 161 浏览
添加回答
举报