我在根网格中有VisualStateManager,但它没有触发AdaptiveTrigger
。我正在尝试更改textblock
内的StackPanel
。此外,VisualState
设置者优先于默认值的规则是什么?例如,textblock
CreateNewAccount
正在使用x:Uid
来获取字符串资源,但当setter
尝试更改Text
值时,哪一个获得优先级?与静态资源样式设置的FontSize
相同。
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Style/ApparentTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="MainGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="20 0 20 0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Mobile_720">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="CreateNewAccount.FontSize" Value="12"/>
<Setter Target="CreateNewAccount.Text" Value="Test"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="FormStackPanel" Grid.Row="0" Grid.Column="1" Orientation="Vertical">
<TextBlock x:Name="CreateNewAccount" x:Uid="CreateNewAccount" Style="{StaticResource TitleTextBlockStyle1366}"/>
<TextBox x:Uid="EmailField" x:Name="emailField"
Style="{StaticResource TextBoxStyle1366}" InputScope="EmailNameOrAddress"
Text="{Binding NewSignUp.Email, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox x:Uid="FirstNameField" x:Name="firstNameField"
Style="{StaticResource TextBoxStyle1366}" InputScope="AlphanumericFullWidth"
Text="{Binding NewSignUp.FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox x:Uid="LastNameField" x:Name="lastNameField"
Style="{StaticResource TextBoxStyle1366}" InputScope="AlphanumericFullWidth"
Text="{Binding NewSignUp.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<PasswordBox x:Uid="PasswordField" x:Name="passwordField"
Style="{StaticResource PasswordBoxStyle1366}"
Password="{Binding NewSignUp.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<PasswordBox x:Uid="PasswordConfirmField" x:Name="passwordConfirmField"
Style="{StaticResource PasswordBoxStyle1366}"
Password="{Binding NewSignUp.PasswordConfirm, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Uid="CreateAccountButton"
Style="{StaticResource ButtonStyle1366}"
Command="{Binding CreateAccountCommand}" Click="CreateAccountButton_Click"/>
<TextBlock x:Name="errorMessage"
FontSize="16pt" Foreground="Red" Margin="0 5 0 0"
Text="{Binding SignUpErrorMessage, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
<ProgressRing x:Name="signUpProgressRing"
HorizontalAlignment="Center" IsActive="False" Height="30" Width="30"/>
</StackPanel>
</Grid>
答案 0 :(得分:0)
最好设计一个小的外形尺寸,并使用AdaptiveTrigger
来获得更大的宽度和高度。因为我正在做相反的事情,并且在较小的移动屏幕上进行测试,我无法看到这些变化。这是经修订的XAML:
<Page
x:Class="apparent_uwp.View.SignUpPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:apparent_uwp.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Style/ApparentTheme.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Page.Resources>
<Grid x:Name="MainGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="20 0 20 0">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="Mobile_720">
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="720" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="CreateNewAccount.FontSize" Value="24"/>
<Setter Target="MainGrid.ColumnDefinitions[0].Width" Value="*"/>
<Setter Target="MainGrid.ColumnDefinitions[2].Width" Value="*"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="FormStackPanel" Grid.Row="0" Grid.Column="1" Orientation="Vertical" Margin="10 0 10 0">
<TextBlock x:Name="CreateNewAccount" x:Uid="CreateNewAccount" Style="{StaticResource TitleTextBlockStyle}"/>
<TextBox x:Uid="EmailField" x:Name="emailField"
Style="{StaticResource TextBoxStyle}" InputScope="EmailNameOrAddress"
Text="{Binding NewSignUp.Email, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox x:Uid="FirstNameField" x:Name="firstNameField"
Style="{StaticResource TextBoxStyle}" InputScope="AlphanumericFullWidth"
Text="{Binding NewSignUp.FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBox x:Uid="LastNameField" x:Name="lastNameField"
Style="{StaticResource TextBoxStyle}" InputScope="AlphanumericFullWidth"
Text="{Binding NewSignUp.LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<PasswordBox x:Uid="PasswordField" x:Name="passwordField"
Style="{StaticResource PasswordBoxStyle}"
Password="{Binding NewSignUp.Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<PasswordBox x:Uid="PasswordConfirmField" x:Name="passwordConfirmField"
Style="{StaticResource PasswordBoxStyle}"
Password="{Binding NewSignUp.PasswordConfirm, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<Button x:Uid="CreateAccountButton"
Style="{StaticResource ButtonStyle}"
Command="{Binding CreateAccountCommand}" Click="CreateAccountButton_Click"/>
<TextBlock x:Name="errorMessage"
FontSize="16pt" Foreground="Red" Margin="0 5 0 0"
Text="{Binding SignUpErrorMessage, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
<ProgressRing x:Name="signUpProgressRing"
HorizontalAlignment="Center" IsActive="False" Height="30" Width="30"/>
</StackPanel>
</Grid>