我想在运行时更改网格的颜色,并在 mainpage.xaml 的 gridview 中显示此项目模板...这里我尝试过此项目模板在 StandardStyle.xaml 中...
<DataTemplate x:Key="Standard250x250ItemTemplate">
<Grid Name="grid1" HorizontalAlignment="Left" Width="370" Height="200">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition ></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.ColumnSpan="2" Grid.Row="0" Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Height="30">
<!--<Image Source="{Binding Image}" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>-->
<TextBlock Text="{Binding ProjectName}" FontSize="20" Foreground="#FFCBD3D4" Style="{StaticResource TitleTextStyle}" TextAlignment="Center"/>
</Border>
<StackPanel Name="spname" Width="Auto" Grid.Column="0" Grid.Row="1" Orientation="Vertical" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}" VerticalAlignment="Stretch">
<TextBlock Text=" Project Code " FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" Width="200" TextAlignment="Left" />
<TextBlock Text=" ProjectManager" FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" Width="200" TextAlignment="Left" />
<TextBlock Text=" Project Status " FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" Width="200" TextAlignment="Left" />
</StackPanel>
<StackPanel Name="sp1" Width="200" Orientation="Vertical" Grid.Column="1" Grid.Row="1" Background="{StaticResource ListViewItemOverlayBackgroundThemeBrush}">
<TextBlock Text="{Binding ProjectCode}" FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" TextAlignment="Center" />
<TextBlock Text="{Binding ProjectManagerName}" FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" TextAlignment="Center" />
<TextBlock x:Name="statusblock" Text="{Binding ProjectStatus}" FontSize="25" TextWrapping="NoWrap" Foreground="{StaticResource ListViewItemOverlaySecondaryForegroundThemeBrush}" Height="50" TextAlignment="Center" />
</StackPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition From="Normal" To="Colored" GeneratedDuration="00:00:01"></VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal"/>
<VisualState x:Name="Colored">
<Storyboard>
<ColorAnimation Storyboard.TargetName="grid1" Storyboard.TargetProperty="Background" To="Red" >
</ColorAnimation>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</DataTemplate>