SolidColorBrush 单一颜色填充
LinearGradientBrush渐变涂刷,GradientStop 代表一个颜色
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button Content="Button" HorizontalAlignment="Left" Margin="71,68,0,0" VerticalAlignment="Top" RenderTransformOrigin="-1.158,-0.553" Height="157" Width="283"> <Button.Background> <!--<SolidColorBrush Color="Gold"></SolidColorBrush>--> <LinearGradientBrush> <GradientStop Color="Red" Offset="0"></GradientStop> <GradientStop Color="Yellow" Offset="0.70"></GradientStop> <GradientStop Color="Blue" Offset="1"></GradientStop> </LinearGradientBrush> </Button.Background> </Button> <TextBlock HorizontalAlignment="Left" Margin="74,275,0,0" TextWrapping="Wrap" Text="想想大发大地方" FontSize="50" VerticalAlignment="Top" Height="77" Width="427"> <TextBlock.Foreground> <LinearGradientBrush> <GradientStop Color="Red"></GradientStop> <GradientStop x:Name="gs1" Color="Red" Offset="0.1"></GradientStop> <GradientStop x:Name="gs2" Color="Blue" Offset="0.1"></GradientStop> <GradientStop Color="Blue" Offset="1"></GradientStop> </LinearGradientBrush> </TextBlock.Foreground> </TextBlock> </Grid>
如何让文字以歌词的形式走起来
protected override void OnNavigatedTo(NavigationEventArgs e) { DispatcherTimer time = new DispatcherTimer(); time.Interval = TimeSpan.FromMilliseconds(100); time.Tick+=time_Tick; time.Start(); } private void time_Tick(object sender, object e) { if (gs1.Offset > 1) { gs1.Offset = 0; gs2.Offset = 0; } else { gs1.Offset += 0.01; gs2.Offset += 0.01; } }